Module: YieldFrom

Defined in:
lib/yield_from.rb

Constant Summary collapse

VERSION =
'0.0.0.1'

Instance Method Summary collapse

Instance Method Details

#yield_from(*funcsyms) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/yield_from.rb', line 38

def yield_from(*funcsyms)
  funcsyms.each{|funcsym|
    func = instance_method(funcsym)
    define_method(funcsym){|*args,&blk|
      return to_enum(funcsym,*args) if !blk
      func.bind(self).(*args){|*a|a.each{|e|blk.(e)}}
    }
  }
end