Class: Commutator::Options::Proxy::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/commutator/options/proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, args, block) ⇒ Operation

Returns a new instance of Operation.



17
18
19
20
21
# File 'lib/commutator/options/proxy.rb', line 17

def initialize(method, args, block)
  @method = method
  @args = args
  @block = block
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



15
16
17
# File 'lib/commutator/options/proxy.rb', line 15

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



15
16
17
# File 'lib/commutator/options/proxy.rb', line 15

def block
  @block
end

#methodObject (readonly)

Returns the value of attribute method.



15
16
17
# File 'lib/commutator/options/proxy.rb', line 15

def method
  @method
end

Instance Method Details

#apply(options, chainable_history = nil) ⇒ Object



23
24
25
26
27
28
# File 'lib/commutator/options/proxy.rb', line 23

def apply(options, chainable_history = nil)
  options.send(method, *args, &block).tap do |result|
    # if result == self then that was a call to #with_context
    chainable_history << self if chainable_history && result == options
  end
end