Class: Sablon::Expression::LookupOrMethodCall
- Inherits:
-
Struct
- Object
- Struct
- Sablon::Expression::LookupOrMethodCall
- Defined in:
- lib/sablon/operations.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#receiver_expr ⇒ Object
Returns the value of attribute receiver_expr.
Instance Method Summary collapse
Instance Attribute Details
#expression ⇒ Object
Returns the value of attribute expression
167 168 169 |
# File 'lib/sablon/operations.rb', line 167 def expression @expression end |
#receiver_expr ⇒ Object
Returns the value of attribute receiver_expr
167 168 169 |
# File 'lib/sablon/operations.rb', line 167 def receiver_expr @receiver_expr end |
Instance Method Details
#evaluate(context) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/sablon/operations.rb', line 168 def evaluate(context) if receiver = receiver_expr.evaluate(context) expression.split(".").inject(receiver) do |local, m| case local when Hash local[m] else local.public_send m if local.respond_to?(m) end end end end |
#inspect ⇒ Object
181 182 183 |
# File 'lib/sablon/operations.rb', line 181 def inspect "«#{receiver_expr.name}.#{expression}»" end |