Method: Copland::ClassFactory#create_pool
- Defined in:
- lib/copland/class-factory.rb
#create_pool(name, &block) ⇒ Object
Define a new pool with the given name. If a block is given, it should accept at least one parameter (the klass to instantiate) and should return an instance of that class. Additional parameters may be passed to the block, with the intent that they may be used to initialize the new object somehow.
57 58 59 60 61 |
# File 'lib/copland/class-factory.rb', line 57 def create_pool( name, &block ) block ||= proc { |k,*args| k.new( *args ) } @pools[ name ] = Hash.new @constructors[ name ] = block end |