Module: Gonzales::Adapter
- Defined in:
- lib/gonzales/adapter.rb,
lib/gonzales/adapter/registered.rb,
lib/gonzales/adapter/unregistered.rb
Overview
Gonzales::Adapter
Adapter for instantiating factories in database
Defined Under Namespace
Classes: Registered, Unregistered
Class Method Summary collapse
-
.create(factory_name, *options) ⇒ Object
Instantiates a record in the database with the defined factory.
-
.use(name) ⇒ Object
Sets the adapter to be used for instantiating objects based on predefioned factories.
Class Method Details
.create(factory_name, *options) ⇒ Object
Instantiates a record in the database with the defined factory. This is an internal method.
The method will call either registered or unregistered adapter, depending on what was defined in the use method.
37 38 39 40 |
# File 'lib/gonzales/adapter.rb', line 37 def self.create(factory_name, *) @@adapter ||= Unregistered @@adapter.create(factory_name, *) end |
.use(name) ⇒ Object
Sets the adapter to be used for instantiating objects based on predefioned factories. Internal.
44 45 46 47 |
# File 'lib/gonzales/adapter.rb', line 44 def self.use(name) raise ArgumentError unless %w(registered unregistered).include? name.to_s @@adapter = "#{self}::#{name.to_s.classify}".constantize end |