Module: ChainableMethods

Defined in:
lib/chainable_methods.rb,
lib/chainable_methods/version.rb

Defined Under Namespace

Modules: Nil Classes: Link

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/chainable_methods.rb', line 12

def self.included(base)
  base.extend(self)
  begin
    # this way the module doesn't have to declare all methods as class methods
    base.extend(base) if base.kind_of?(Module)
  rescue TypeError
    # wrong argument type Class (expected Module)
  end
end

Instance Method Details

#chain_from(initial_state, context = self) ⇒ Object



22
23
24
# File 'lib/chainable_methods.rb', line 22

def chain_from(initial_state, context = self)
  ChainableMethods::Link.new(initial_state, context)
end