public
Last active

Wrapping multiple objects in ruby

  • Download Gist
multiplexer.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11
# Multiplexer - multiple objects wrapped in one object
# written by Jared Grippe jared@change.org
class Multiplexer
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
def initialize *objects
@__objects__ = objects
end
def method_missing(sym, *args, &block)
@__objects__.map{|io| io.__send__(sym, *args, &block) }.first
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.