Class: ActionView::Helpers::JavaScriptProxy

Inherits:
ActiveSupport::BasicObject
Defined in:
lib/action_view/helpers/prototype_helper.rb

Overview

Converts chained method calls on DOM proxy elements into JavaScript chains

Instance Method Summary collapse

Constructor Details

#initialize(generator, root = nil) ⇒ JavaScriptProxy

:nodoc:



659
660
661
662
# File 'lib/action_view/helpers/prototype_helper.rb', line 659

def initialize(generator, root = nil)
  @generator = generator
  @generator << root if root
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) ⇒ Object (private)



669
670
671
672
673
674
675
# File 'lib/action_view/helpers/prototype_helper.rb', line 669

def method_missing(method, *arguments, &block)
  if method.to_s =~ /(.*)=$/
    assign($1, arguments.first)
  else
    call("#{method.to_s.camelize(:lower)}", *arguments, &block)
  end
end

Instance Method Details

#is_a?(klass) ⇒ Boolean

Returns:

  • (Boolean)


664
665
666
# File 'lib/action_view/helpers/prototype_helper.rb', line 664

def is_a?(klass)
  klass == JavaScriptProxy
end