Class: Macros4Cuke::VariableRep
- Inherits:
-
Object
- Object
- Macros4Cuke::VariableRep
- Defined in:
- lib/macros4cuke/template-engine.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(aVarName) ⇒ VariableRep
constructor
A new instance of VariableRep.
-
#render(aContextObject, theLocals) ⇒ Object
The signature of this method should comply to the Tilt API.
Constructor Details
#initialize(aVarName) ⇒ VariableRep
Returns a new instance of VariableRep.
28 29 30 |
# File 'lib/macros4cuke/template-engine.rb', line 28 def initialize(aVarName) @name = aVarName end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
26 27 28 |
# File 'lib/macros4cuke/template-engine.rb', line 26 def name @name end |
Instance Method Details
#render(aContextObject, theLocals) ⇒ Object
The signature of this method should comply to the Tilt API. Actual values from the ‘locals’ Hash take precedence over the context object.
35 36 37 38 39 40 41 42 43 |
# File 'lib/macros4cuke/template-engine.rb', line 35 def render(aContextObject, theLocals) actual_value = theLocals[name] if actual_value.nil? actual_value = aContextObject.send(name.to_sym) if aContextObject.respond_to?(name.to_sym) actual_value = '' if actual_value.nil? end return actual_value.is_a?(String) ? actual_value : actual_value.to_s end |