Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/abstract_method.rb
Instance Method Summary collapse
-
#abstract_method(*names) ⇒ Object
Defines one or more abstract methods with given names in a class or module.
Instance Method Details
#abstract_method(*names) ⇒ Object
Defines one or more abstract methods with given names in a class or module. When called, the abstract method will raise an ‘AbstractMethodCalled` exception with a helpful message.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/abstract_method.rb', line 32 def abstract_method(*names) definitor = self names.each do |name| define_method name do |*args| raise AbstractMethodCalled, "Called unimplemented abstract method #{self.class}##{name} " + "(defined in #{definitor.class.name.downcase} #{definitor})." end end end |