Class: VersatileRJS::Proxy::Jquery::EachProxy

Inherits:
EachProxy show all
Defined in:
lib/versatile_rjs/proxy/jquery/each_proxy.rb

Constant Summary

Constants included from Container

Container::DELIMITER_WITHOUT_NEW_LINE, Container::DELIMITER_WITH_NEW_LINE

Instance Attribute Summary

Attributes inherited from EachProxy

#variable_name

Instance Method Summary collapse

Methods inherited from EachProxy

#each, #next_variable_count, #statement

Methods included from Container

#add_statement, #statements, #to_script

Methods inherited from VersatileRJS::Proxy

#call, #method_missing, #to_json

Constructor Details

#initialize(page) ⇒ EachProxy

Returns a new instance of EachProxy.



5
6
7
8
# File 'lib/versatile_rjs/proxy/jquery/each_proxy.rb', line 5

def initialize(page)
  super
  add_statement(ActiveSupport::JSON::Variable.new("var #{variable_name} = $(#{tmp_variable_name})"))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class VersatileRJS::Proxy

Instance Method Details

#statement_prefix(statement) ⇒ Object



14
15
16
17
# File 'lib/versatile_rjs/proxy/jquery/each_proxy.rb', line 14

def statement_prefix(statement)
  loop_variable_name = "_loop" + variable_name
  "$.each(function(#{loop_variable_name}, #{tmp_variable_name}){"
end

#statement_suffix(statement) ⇒ Object



19
20
21
# File 'lib/versatile_rjs/proxy/jquery/each_proxy.rb', line 19

def statement_suffix(statement)
  "})"
end

#tmp_variable_nameObject



10
11
12
# File 'lib/versatile_rjs/proxy/jquery/each_proxy.rb', line 10

def tmp_variable_name
  @tmp_variable_name ||= "_tmp" + variable_name
end