Module: TimeExt::MethodChain
- Included in:
- Time
- Defined in:
- lib/time_ext/method_chain.rb
Instance Method Summary (collapse)
Instance Method Details
- (Object) add_to_chain(method, *args, &block)
4 5 6 7 |
# File 'lib/time_ext/method_chain.rb', line 4 def add_to_chain(method, *args, &block) @method_chain ||= [] @method_chain << [method.to_sym, args, block] end |
- (Object) call_chain(custom_block = nil, &block)
9 10 11 12 13 14 15 |
# File 'lib/time_ext/method_chain.rb', line 9 def call_chain(custom_block = nil, &block) method, args, iblock = @method_chain.pop return nil if method.nil? iblock = custom_block if !custom_block.nil? method, args, iblock = yield(method, args, iblock) if block_given? self.send(method, *args, &iblock) end |