Module: EasyCommand::Chainable

Included in:
Result
Defined in:
lib/easy_command/chainable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



12
13
14
# File 'lib/easy_command/chainable.rb', line 12

def self.included(klass)
  klass.define_method(:call) { self } unless klass.instance_methods.include? :call
end

Instance Method Details

#then(other) ⇒ Object Also known as: |



3
4
5
6
7
8
9
# File 'lib/easy_command/chainable.rb', line 3

def then(other)
  if success?
    other.call(result)
  else
    self
  end
end