Module: FixtureFactory
- Defined in:
- lib/fixture_factory.rb,
lib/fixture_factory/errors.rb,
lib/fixture_factory/methods.rb,
lib/fixture_factory/version.rb,
lib/fixture_factory/registry.rb,
lib/fixture_factory/sequence.rb,
lib/fixture_factory/definition.rb
Defined Under Namespace
Modules: Methods, Registry Classes: Definition, Error, NotFoundError, Sequence, WrongClassError, WrongFixtureMethodError
Constant Summary collapse
- VERSION =
"0.3.0"
Class Method Summary collapse
-
.attributes_for(name, **options) ⇒ Object
:nodoc:.
-
.build(name, **options) ⇒ Object
:nodoc:.
-
.create(name, **options) ⇒ Object
:nodoc:.
-
.evaluate(block, args: [], context:) ⇒ Object
:nodoc:.
Class Method Details
.attributes_for(name, **options) ⇒ Object
:nodoc:
12 13 14 15 |
# File 'lib/fixture_factory.rb', line 12 def attributes_for(name, **) # :nodoc: _, attributes = retrieve(name, **) attributes end |
.build(name, **options) ⇒ Object
:nodoc:
17 18 19 20 |
# File 'lib/fixture_factory.rb', line 17 def build(name, **) # :nodoc: klass, attributes = retrieve(name, **) klass.new(attributes) end |
.create(name, **options) ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/fixture_factory.rb', line 22 def create(name, **) # :nodoc: build(name, **).tap(&:save!) end |
.evaluate(block, args: [], context:) ⇒ Object
:nodoc:
26 27 28 29 |
# File 'lib/fixture_factory.rb', line 26 def evaluate(block, args: [], context:) # :nodoc: attributes = context.instance_exec(*args, &block) extract_attributes(attributes) end |