Module: AbstractClass
- Included in:
- RLTK::CG::AggregateType, RLTK::CG::BasicIntType, RLTK::CG::Constant, RLTK::CG::ConstantAggregate, RLTK::CG::ConstantInteger, RLTK::CG::ConstantNumber, RLTK::CG::ConstantReal, RLTK::CG::ExecutionEngine, RLTK::CG::NumberType, RLTK::CG::RealType, RLTK::CG::SimpleAggregateType, RLTK::CG::SimpleIntType, RLTK::CG::SimpleType, RLTK::CG::Type, RLTK::CG::User
- Defined in:
- lib/rltk/util/abstract_class.rb
Overview
A module used for making abstract classes. Any class that includes this module will not be able to be instantiated directly.
Class Method Summary collapse
-
.included(klass) ⇒ Object
Callback method for when this module is included.
Class Method Details
.included(klass) ⇒ Object
Callback method for when this module is included.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rltk/util/abstract_class.rb', line 12 def self.included(klass) klass.instance_exec do @abstract_class = klass def self.new(*args) if self == @abstract_class raise "Instantiating abstract class #{self} is not allowed." else super end end end end |