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

Class Method Details

.attributes_for(name, **options) ⇒ Object

:nodoc:



12
13
14
15
# File 'lib/fixture_factory.rb', line 12

def attributes_for(name, **options) # :nodoc:
  _, attributes = retrieve(name, **options)
  attributes
end

.build(name, **options) ⇒ Object

:nodoc:



17
18
19
20
# File 'lib/fixture_factory.rb', line 17

def build(name, **options) # :nodoc:
  klass, attributes = retrieve(name, **options)
  klass.new(attributes)
end

.create(name, **options) ⇒ Object

:nodoc:



22
23
24
# File 'lib/fixture_factory.rb', line 22

def create(name, **options) # :nodoc:
  build(name, **options).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