class window.AttachBehavior

  constructor: ->
    $(document).ready(@attach)
    $(document).ajaxComplete(@attach)
    $.subscribe('behaviors.attach', @attach)

  attach: ->
    $('[data-behavior]').each (index, dom) ->
      domKlass = $(dom).data('behavior')
      klass = window[domKlass]
      throw new Error('No valid js Behavior: ' + domKlass) unless klass?
      object = new klass(dom)

new AttachBehavior()
