Module: ROM::Factory

Includes:
Dry::Core::Constants
Defined in:
lib/rom/factory.rb,
lib/rom/factory/dsl.rb,
lib/rom/factory/builder.rb,
lib/rom/factory/version.rb,
lib/rom/factory/registry.rb,
lib/rom/factory/constants.rb,
lib/rom/factory/factories.rb,
lib/rom/factory/sequences.rb,
lib/rom/factory/attributes.rb,
lib/rom/factory/tuple_evaluator.rb,
lib/rom/factory/attributes/value.rb,
lib/rom/factory/attribute_registry.rb,
lib/rom/factory/attributes/callable.rb,
lib/rom/factory/attributes/sequence.rb,
lib/rom/factory/builder/persistable.rb,
lib/rom/factory/attributes/association.rb

Overview

Main ROM::Factory API

Defined Under Namespace

Modules: Attributes Classes: DSL, Factories, FactoryNotDefinedError, Structs, UnknownFactoryAttributes

Constant Summary collapse

DEFAULT_NAME =
'Factories'.freeze
VERSION =
'0.9.1'

Class Method Summary collapse

Class Method Details

.configure(name = DEFAULT_NAME, &block) ⇒ Class

Configure a new factory

Examples:

MyFactory = ROM::Factory.configure do |config|
  config.rom = my_rom_container
end

Parameters:

  • name (Symbol) (defaults to: DEFAULT_NAME)

    An optional factory class name

Returns:

  • (Class)


25
26
27
28
29
30
31
# File 'lib/rom/factory.rb', line 25

def self.configure(name = DEFAULT_NAME, &block)
  klass = Dry::Core::ClassBuilder.new(name: name, parent: Factories).call do |klass|
    klass.configure(&block)
  end

  klass.new(klass.config.rom)
end