Method: Module#abstract
- Defined in:
- lib/core/facets/module/abstract.rb
#abstract(*sym) ⇒ Object
Create an abstract method. If it is not overridden, it will raise a TypeError when called.
class AbstractExample
abstract :a
end
c = AbstractExample.new
expect TypeError do
c.a
end
CREDIT: Trans
18 19 20 21 22 |
# File 'lib/core/facets/module/abstract.rb', line 18 def abstract(*sym) sym.each do |s| define_method(s){ raise TypeError, "undefined abstraction ##{s}" } end end |