It is very easy to return a method, for example, proc from a module:
module Foo def self.bar # Method implementation end def self.baz # Method implementation end def self.qux # Method implemenatation end def self.zoo # Method implementation end end Foo.method(:bar) # Returns a proc object
But what if I want to return more than one method (but not all) from the same module? One way to do this is: [:bar,:baz].inject([]) {|memo,i| memo << Foo.method(i)} [:bar,:baz].inject([]) {|memo,i| memo << Foo.method(i)}
Is there a better, more flexible way to do the same?
source share