Class: VersatileRJS::Proxy::EachProxy
- Inherits:
-
VersatileRJS::Proxy
- Object
- VersatileRJS::Proxy
- VersatileRJS::Proxy::EachProxy
- Includes:
- Container
- Defined in:
- lib/versatile_rjs/proxy/each_proxy.rb
Direct Known Subclasses
Constant Summary
Constants included from Container
Container::DELIMITER_WITHOUT_NEW_LINE, Container::DELIMITER_WITH_NEW_LINE
Instance Attribute Summary collapse
-
#variable_name ⇒ Object
readonly
Returns the value of attribute variable_name.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(page) ⇒ EachProxy
constructor
A new instance of EachProxy.
- #next_variable_count ⇒ Object
- #statement ⇒ Object
- #statement_prefix(statement) ⇒ Object
- #statement_suffix(statement) ⇒ Object
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.
9 10 11 12 |
# File 'lib/versatile_rjs/proxy/each_proxy.rb', line 9 def initialize(page) super(page, nil) self.variable_name = "_v#{next_variable_count}" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class VersatileRJS::Proxy
Instance Attribute Details
#variable_name ⇒ Object (readonly)
Returns the value of attribute variable_name.
5 6 7 |
# File 'lib/versatile_rjs/proxy/each_proxy.rb', line 5 def variable_name @variable_name end |
Instance Method Details
#each ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/versatile_rjs/proxy/each_proxy.rb', line 14 def each page.push_container(self) element = ElementProxy.new_instance(page, variable_name) begin yield element page.append_statement statement ensure page.pop_container end end |
#next_variable_count ⇒ Object
31 32 33 34 |
# File 'lib/versatile_rjs/proxy/each_proxy.rb', line 31 def next_variable_count count = Thread.current[:__versatile_rjs_each_var_counter] || -1 Thread.current[:__versatile_rjs_each_var_counter] += 1 end |
#statement ⇒ Object
25 26 |
# File 'lib/versatile_rjs/proxy/each_proxy.rb', line 25 def statement end |
#statement_prefix(statement) ⇒ Object
28 |
# File 'lib/versatile_rjs/proxy/each_proxy.rb', line 28 def statement_prefix(statement);end |
#statement_suffix(statement) ⇒ Object
29 |
# File 'lib/versatile_rjs/proxy/each_proxy.rb', line 29 def statement_suffix(statement);end |