Class: Copland::Instantiator::Simple
- Defined in:
- lib/copland/instantiator/simple.rb
Overview
A simple instantiator is used for instantiating a class. It does no other work than that.
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#instantiate ⇒ Object
Takes the definition data that was given when the instantiator was created and treats it as the path to and name of the class to instantiate.
Methods inherited from Abstract
#initialize, register_as, #validate!
Constructor Details
This class inherits a constructor from Copland::Instantiator::Abstract
Instance Method Details
#instantiate ⇒ Object
Takes the definition data that was given when the instantiator was created and treats it as the path to and name of the class to instantiate. This class is then instantiated and returned. This requires that the class have a no-argument constructor.
If the class includes the Singleton module, then the singleton instance of the class will be returned.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/copland/instantiator/simple.rb', line 52 def instantiate unless @klass @klass = Copland::get_class( definition ) end if @klass.include?( Singleton ) @klass.instance else @klass.new end end |