Class: Greased::MethodCaller
- Inherits:
-
Object
- Object
- Greased::MethodCaller
- Defined in:
- lib/greased/method_caller.rb
Instance Method Summary collapse
- #call(target, name, value) ⇒ Object
-
#initialize(operator = nil, options = {}) ⇒ MethodCaller
constructor
A new instance of MethodCaller.
Constructor Details
#initialize(operator = nil, options = {}) ⇒ MethodCaller
Returns a new instance of MethodCaller.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/greased/method_caller.rb', line 4 def initialize(operator = nil, = {}) @operator = operator @evaluations = [] if @operator.nil? @evaluations << :default elsif @operator == "=" @evaluations << :assign else @evaluations << :evaluate end if [:reassign] @evaluations << :assign end end |
Instance Method Details
#call(target, name, value) ⇒ Object
21 22 23 24 25 |
# File 'lib/greased/method_caller.rb', line 21 def call(target, name, value) @evaluations.inject(value) do |result, evaluator| send(evaluator, target, name, result) end end |