Module: Punchout::Punchable
- Defined in:
- lib/punchout.rb
Overview
Classes that include this module become punchable.
Calling ‘Instance#punch(obj)`, will return a class, the class of which is determined by one or more characteristics of `obj`
Instance Attribute Summary collapse
-
#matcher ⇒ Object
An instance of something that acts like a Matcher.
Instance Method Summary collapse
- #punch(obj) ⇒ Class
-
#punchable? ⇒ Boolean
Indicates whether this module is punchable.
-
#puncher ⇒ Puncher
The Puncher assocated with this punchable.
Instance Attribute Details
#matcher ⇒ Object
An instance of something that acts like a Matcher
20 21 22 |
# File 'lib/punchout.rb', line 20 def matcher @matcher end |
Instance Method Details
#punch(obj) ⇒ Class
Punches a class based on the object passed and the Matchers tied to this Punchout::Punchable
34 35 36 |
# File 'lib/punchout.rb', line 34 def punch(obj) puncher.punch(obj) end |
#punchable? ⇒ Boolean
Indicates whether this module is punchable
TODO: This method might become an indication of whether any punchers are registered. Or it just might die. Not sure yet.
15 16 17 |
# File 'lib/punchout.rb', line 15 def punchable? true end |
#puncher ⇒ Puncher
The Punchout::Puncher assocated with this punchable.
25 26 27 |
# File 'lib/punchout.rb', line 25 def puncher @puncher ||= Puncher.new end |