Module: BlockChainable::ClassMethods

Defined in:
lib/block_chainable.rb

Instance Method Summary collapse

Instance Method Details

#inherited(klass) ⇒ Object



21
22
23
# File 'lib/block_chainable.rb', line 21

def inherited(klass)
  klass.class_eval{include BlockChainable}
end

#start(*args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/block_chainable.rb', line 3

def start(*args,&block)
  klass_instance = self.new(*args)
  
  klass_instance.instance_variable_set("@__parent",eval("self",block))
  
  class << klass_instance
    def method_missing(name,*args,&block)
      if chain_respond_to?(name)
        @__parent.send(name,*args,&block)
      else
        super
      end
    end
  end
  
  klass_instance.instance_eval(&block)
end