Class: Patme::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/patme/method.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Method

Returns a new instance of Method.



4
5
6
7
# File 'lib/patme/method.rb', line 4

def initialize(name)
  @name = name
  @implementations = []
end

Instance Method Details

#add_implementation(implementation) ⇒ Object



9
10
11
# File 'lib/patme/method.rb', line 9

def add_implementation(implementation)
  @implementations << implementation
end

#call(object, args) ⇒ Object



17
18
19
# File 'lib/patme/method.rb', line 17

def call(object, args)
  @implementations.find{|i| i.match?(args)}.call(object, args)
end

#implemented_for?(args) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/patme/method.rb', line 13

def implemented_for?(args)
  @implementations.any?{|i| i.match?(args)}
end