Class: Patme::Method
- Inherits:
-
Object
- Object
- Patme::Method
- Defined in:
- lib/patme/method.rb
Instance Method Summary collapse
- #add_implementation(implementation) ⇒ Object
- #call(object, args) ⇒ Object
- #implemented_for?(args) ⇒ Boolean
-
#initialize(name) ⇒ Method
constructor
A new instance of Method.
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
13 14 15 |
# File 'lib/patme/method.rb', line 13 def implemented_for?(args) @implementations.any?{|i| i.match?(args)} end |