Class: Proteus::InstanceProxy
- Inherits:
-
Object
- Object
- Proteus::InstanceProxy
- Defined in:
- lib/InstanceProxy.rb
Overview
Provides the environment for rendering templates.
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#instance ⇒ Object
Returns the value of attribute instance.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#props ⇒ Object
Returns the value of attribute props.
-
#renderer ⇒ Object
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#initialize(renderer, instance) ⇒ InstanceProxy
constructor
————————————————————————— Constructor —————————————————————————.
-
#instance_env ⇒ Object
Returns the binding in the scope of the proxy instance.
-
#method_missing(m, *args) ⇒ Object
Redirects missing method calls to the property hash.
-
#next_child ⇒ Object
Returns the next child, or nil.
Constructor Details
#initialize(renderer, instance) ⇒ InstanceProxy
Constructor
39 40 41 42 43 44 45 46 47 |
# File 'lib/InstanceProxy.rb', line 39 def initialize( renderer, instance ) @renderer = renderer @instance = instance @kind = @instance.kind @properties = @instance.final_properties @props = PropertyHash.new( @properties, @renderer ) @children = @instance.children end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
Redirects missing method calls to the property hash.
77 78 79 |
# File 'lib/InstanceProxy.rb', line 77 def method_missing(m, *args) @props[ m.to_s ] end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
57 58 59 |
# File 'lib/InstanceProxy.rb', line 57 def children @children end |
#instance ⇒ Object
Returns the value of attribute instance.
57 58 59 |
# File 'lib/InstanceProxy.rb', line 57 def instance @instance end |
#kind ⇒ Object
Returns the value of attribute kind.
57 58 59 |
# File 'lib/InstanceProxy.rb', line 57 def kind @kind end |
#properties ⇒ Object
Returns the value of attribute properties.
57 58 59 |
# File 'lib/InstanceProxy.rb', line 57 def properties @properties end |
#props ⇒ Object
Returns the value of attribute props.
57 58 59 |
# File 'lib/InstanceProxy.rb', line 57 def props @props end |
#renderer ⇒ Object
Returns the value of attribute renderer.
57 58 59 |
# File 'lib/InstanceProxy.rb', line 57 def renderer @renderer end |
Instance Method Details
#instance_env ⇒ Object
Returns the binding in the scope of the proxy instance.
70 71 72 |
# File 'lib/InstanceProxy.rb', line 70 def instance_env( ) return binding() end |
#next_child ⇒ Object
Returns the next child, or nil.
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/InstanceProxy.rb', line 84 def next_child if @_last_child_index.nil? @last_child = nil @_last_child_index = 0 return renderer.render( children[0] ) end @last_child = children[ @_last_child_index ] @_last_child_index += 1 return renderer.render( children[ @_last_child_index ] ) end |