Virtual method declaration.
A virtual method is a method which is inheritable and overridable. Since all methods in ruby are virtual, syntax is not required to provide this capability.
When developing framework style code, it is often required to override or implement a specific method in order to satisfy a contract. The purpose of this library is to provide a way for a developer of framework code to convey that intent.
The virtual
and pure_virtual
macros can be added to all classes with:
require 'virtual'; Virtual.activate
Optionally, they can be applied to a single class with Virtual.activate(MyClass)
virtual
is an indication that a method may be overridden.
pure_virtual
is an indication that a method must be overridden (if it is not, an error will be raised when called).
class MyClass
virtual :my_optional_method
pure_virtual :my_required_method
end
The virtual
library is released under the MIT License.