Class RR::WildcardMatchers::DuckType
In: lib/rr/wildcard_matchers/duck_type.rb
Parent: Object

Methods

==   eql?   inspect   new   wildcard_match?  

Attributes

required_methods  [RW] 

Public Class methods

[Source]

   # File lib/rr/wildcard_matchers/duck_type.rb, line 6
6:       def initialize(*required_methods)
7:         @required_methods = required_methods
8:       end

Public Instance methods

[Source]

    # File lib/rr/wildcard_matchers/duck_type.rb, line 25
25:       def ==(other)
26:         return false unless other.is_a?(self.class)
27:         self.required_methods == other.required_methods
28:       end
eql?(other)

Alias for #==

[Source]

    # File lib/rr/wildcard_matchers/duck_type.rb, line 18
18:       def inspect
19:         formatted_required_methods = required_methods.collect do |method_name|
20:           method_name.inspect
21:         end.join(', ')
22:         "duck_type(#{formatted_required_methods})"
23:       end

[Source]

    # File lib/rr/wildcard_matchers/duck_type.rb, line 10
10:       def wildcard_match?(other)
11:         return true if self == other
12:         required_methods.each do |m|
13:           return false unless other.respond_to?(m)
14:         end
15:         return true
16:       end

[Validate]