class MirroringTest
Call a same method for multiple receivers
Public Class Methods
new(*receivers)
click to toggle source
# File lib/mirroring_test.rb, line 5 def initialize(*receivers) @receivers = receivers end
Public Instance Methods
class()
click to toggle source
# File lib/mirroring_test.rb, line 9 def class @receivers.first.class end
is_a?(mod)
click to toggle source
# File lib/mirroring_test.rb, line 13 def is_a?(mod) @receivers.first.is_a?(mod) end
Also aliased as: kind_of?, instance_of?
Private Instance Methods
method_missing(method_name, *args, &block)
click to toggle source
# File lib/mirroring_test.rb, line 22 def method_missing(method_name, *args, &block) first_ret_pair = @receivers.map do |r| ret = [nil, nil] next(ret) unless r.respond_to?(method_name) begin ret[0] = r.send(method_name, *args, &block) rescue StandardError => e ret[1] = e end ret end.first raise(first_ret_pair[1]) unless first_ret_pair[1].nil? first_ret_pair[0] end
respond_to_missing?(symbol, include_private)
click to toggle source
Calls superclass method
# File lib/mirroring_test.rb, line 42 def respond_to_missing?(symbol, include_private) @receivers.first.respond_to?(symbol) ? true : super end