class RR::WildcardMatchers::DuckType
Attributes
Public Class Methods
Source
# File lib/rr/wildcard_matchers/duck_type.rb, line 6 def initialize(*required_methods) @required_methods = required_methods end
Public Instance Methods
Source
# File lib/rr/wildcard_matchers/duck_type.rb, line 15 def ==(other) other.is_a?(self.class) && other.required_methods == self.required_methods end
Also aliased as: eql?
Source
# File lib/rr/wildcard_matchers/duck_type.rb, line 21 def inspect formatted_required_methods = required_methods.map { |method_name| method_name.inspect }.join(', ') "duck_type(#{formatted_required_methods})" end
Source
# File lib/rr/wildcard_matchers/duck_type.rb, line 10 def wildcard_match?(other) self == other || required_methods.all? {|m| other.respond_to?(m) } end