Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/license_auto/module.rb
Overview
[Simple and stupid code to emulate pure virtual methods in Ruby](gist.github.com/mssola/6138163)
Here’s the trick: let’s open the Module class and implement the ‘virtual’ method, so it’s available also for classes.
Instance Method Summary collapse
-
#virtual(*methods) ⇒ Object
This method defines a method for each of the elements passed by the variable length argument.
Instance Method Details
#virtual(*methods) ⇒ Object
This method defines a method for each of the elements passed by the variable length argument. The implementation for each method will be just raising a VirtualMethodError coupled with the name of the method.
12 13 14 15 16 |
# File 'lib/license_auto/module.rb', line 12 def virtual(*methods) methods.each do |name| define_method(name) { raise LicenseAuto::VirtualMethodError, name } end end |