# File lib/rr/wildcard_matchers/duck_type.rb, line 6 def initialize(*required_methods) @required_methods = required_methods end
# File lib/rr/wildcard_matchers/duck_type.rb, line 25 def ==(other) return false unless other.is_a?(self.class) self.required_methods == other.required_methods end
# File lib/rr/wildcard_matchers/duck_type.rb, line 18 def inspect formatted_required_methods = required_methods.collect do |method_name| method_name.inspect end.join(', ') "duck_type(#{formatted_required_methods})" end
# File lib/rr/wildcard_matchers/duck_type.rb, line 10 def wildcard_match?(other) return true if self == other required_methods.each do |m| return false unless other.respond_to?(m) end return true end