Class: Build::Environment::Evaluator
- Inherits:
-
Object
- Object
- Build::Environment::Evaluator
- Defined in:
- lib/build/environment/evaluator.rb
Instance Method Summary collapse
-
#initialize(environment) ⇒ Evaluator
constructor
A new instance of Evaluator.
- #method_missing(name) ⇒ Object
-
#object_value(value) ⇒ Object
Compute the literal object value for a given key:.
Constructor Details
#initialize(environment) ⇒ Evaluator
Returns a new instance of Evaluator.
24 25 26 |
# File 'lib/build/environment/evaluator.rb', line 24 def initialize(environment) @environment = environment end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
28 29 30 |
# File 'lib/build/environment/evaluator.rb', line 28 def method_missing(name) object_value(@environment[name]) end |
Instance Method Details
#object_value(value) ⇒ Object
Compute the literal object value for a given key:
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/build/environment/evaluator.rb', line 33 def object_value(value) case value when Array value.collect{|item| object_value(item)}.flatten when Symbol object_value(@environment[value]) when Proc object_value(instance_exec(&value)) when Default object_value(value.value) when Replace object_value(value.value) else value end end |