Module: ModelFactory
- Defined in:
- lib/modelfactory/factory.rb,
lib/modelfactory.rb,
lib/model_factory.rb,
lib/modelfactory/legacy.rb,
lib/modelfactory/version.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Legacy, VERSION Classes: Factory, FactoryConfiguration, Wrapper
Class Method Summary collapse
-
.[](klass) ⇒ Object
Get the Factory for a given model class.
-
.configure(&block) ⇒ Object
Configure the factory singleton by passing a block.
-
.extended(mod) ⇒ Object
Enable legacy API compatibility.
Class Method Details
.[](klass) ⇒ Object
Get the Factory for a given model class.
22 23 24 25 |
# File 'lib/modelfactory.rb', line 22 def self.[](klass) @singleton ||= Wrapper.new @singleton.wrap(klass) end |
.configure(&block) ⇒ Object
Configure the factory singleton by passing a block.
You can call this method multiple times. Each time you do so it will clear the existing configuration and reset the counters.
You don’t need to configure ModelFactory to use it.
17 18 19 |
# File 'lib/modelfactory.rb', line 17 def self.configure(&block) @singleton = Wrapper.new(&block) end |
.extended(mod) ⇒ Object
Enable legacy API compatibility.
28 29 30 |
# File 'lib/modelfactory.rb', line 28 def self.extended(mod) # :nodoc: mod.extend(ModelFactory::Legacy) end |