Interation methods #each, #map_each and more are

implemented and working. Also restructured files
again.
This commit is contained in:
2010-07-29 04:25:42 +03:00
parent d6b65dbc01
commit 438cdd5b68
7 changed files with 184 additions and 58 deletions

View File

@@ -0,0 +1,18 @@
module TimeExt
module MethodChain
def add_to_chain(method, *args, &block)
@method_chain ||= []
@method_chain << [method.to_sym, args, block]
end
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
end
end