Module: Concrete
- Included in:
- IndexedNode, LabeledNode
- Defined in:
- lib/concrete.rb
Overview
Include this module in an abstract class to make it concrete and so, to be able to instantiate it again. This module can be included if and only if the Abstract module has been included before in one of the class’ superclass.
Class Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/concrete.rb', line 9 def self.included(klass) super unless klass.include?(Abstract) raise(TypeError, "#{klass} - not an abstract class") end klass.module_eval do class << self visibility = instance_method_visibility('new') def new(*args, &block) concrete_new(*args, &block) end send(visibility, :new) end def is_a?(klass) klass == Abstract ? false : super(klass) end end end |