Class: VersatileRJS::Proxy
- Inherits:
-
Object
- Object
- VersatileRJS::Proxy
- Defined in:
- lib/versatile_rjs/proxy.rb,
lib/versatile_rjs/proxy/jquery.rb,
lib/versatile_rjs/proxy/each_proxy.rb,
lib/versatile_rjs/proxy/selectable.rb,
lib/versatile_rjs/proxy/element_proxy.rb,
lib/versatile_rjs/proxy/selector_proxy.rb,
lib/versatile_rjs/proxy/expression_proxy.rb,
lib/versatile_rjs/proxy/default_responder.rb,
lib/versatile_rjs/proxy/element_set_proxy.rb,
lib/versatile_rjs/proxy/jquery/each_proxy.rb,
lib/versatile_rjs/proxy/jquery/selectable.rb,
lib/versatile_rjs/proxy/jquery/element_set.rb,
lib/versatile_rjs/proxy/element_by_id_proxy.rb,
lib/versatile_rjs/proxy/framework_dependent.rb,
lib/versatile_rjs/proxy/jquery/element_proxy.rb,
lib/versatile_rjs/proxy/jquery/selector_proxy.rb,
lib/versatile_rjs/proxy/jquery/element_set_proxy.rb,
lib/versatile_rjs/proxy/jquery/element_by_id_proxy.rb
Direct Known Subclasses
Defined Under Namespace
Modules: DefaultResponder, ElementByIdProxy, FrameworkDependent, Jquery, Selectable, SelectorProxy Classes: EachProxy, ElementProxy, ElementSetProxy, ExpressionProxy
Instance Attribute Summary collapse
-
#container ⇒ Object
writeonly
Sets the attribute container.
-
#index ⇒ Object
writeonly
Sets the attribute index.
Instance Method Summary collapse
- #call(method, *arguments) ⇒ Object
-
#initialize(page, statement) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(method, *args) ⇒ Object
- #to_json ⇒ Object (also: #to_s)
Constructor Details
#initialize(page, statement) ⇒ Proxy
Returns a new instance of Proxy.
12 13 14 15 |
# File 'lib/versatile_rjs/proxy.rb', line 12 def initialize(page, statement) @page = page @statement = statement end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
8 9 10 |
# File 'lib/versatile_rjs/proxy.rb', line 8 def method_missing(method, *args) page.append_statement call(method, *args) end |
Instance Attribute Details
#container=(value) ⇒ Object
Sets the attribute container
5 6 7 |
# File 'lib/versatile_rjs/proxy.rb', line 5 def container=(value) @container = value end |
#index=(value) ⇒ Object
Sets the attribute index
5 6 7 |
# File 'lib/versatile_rjs/proxy.rb', line 5 def index=(value) @index = value end |
Instance Method Details
#call(method, *arguments) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/versatile_rjs/proxy.rb', line 17 def call(method, *arguments) method = method.to_s.camelcase(:lower) script = if method =~ /(.*)=$/ "#{statement}.#{$1} = #{arguments.first.to_json}" else "#{statement}.#{method}(#{arguments.map(&:to_json).join(', ')})" end ActiveSupport::JSON::Variable.new script end |
#to_json ⇒ Object Also known as: to_s
28 29 30 |
# File 'lib/versatile_rjs/proxy.rb', line 28 def to_json ActiveSupport::JSON::Variable.new(statement) end |