class RR::WildcardMatchers::DuckType
Attributes
required_methods[RW]
Public Class Methods
new(*required_methods)
click to toggle source
# File lib/rr/wildcard_matchers/duck_type.rb, line 6 def initialize(*required_methods) @required_methods = required_methods end
Public Instance Methods
==(other)
click to toggle 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?
inspect()
click to toggle 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
wildcard_match?(other)
click to toggle 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