Sha256: b9a76046887ea2f03ec2ecdb4580fd2d8c2d2d08ee042111ab9680729945bda5

Contents?: true

Size: 740 Bytes

Versions: 3

Compression:

Stored size: 740 Bytes

Contents

# frozen_string_literal: true

require "dry/core"
require "dry/configurable"
require "dry/struct"

require "rom/factory/factories"

module ROM
  # Main ROM::Factory API
  #
  # @api public
  module Factory
    DEFAULT_NAME = "Factories"

    # Configure a new factory
    #
    # @example
    #   MyFactory = ROM::Factory.configure do |config|
    #     config.rom = my_rom_container
    #   end
    #
    # @param [Symbol] name An optional factory class name
    #
    # @return [Class]
    #
    # @api public
    def self.configure(name = DEFAULT_NAME, &block)
      klass = Dry::Core::ClassBuilder.new(name: name, parent: Factories).call do |c|
        c.configure(&block)
      end

      klass.new(klass.config.rom)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-factory-0.13.0 lib/rom/factory.rb
rom-factory-0.12.0 lib/rom/factory.rb
rom-factory-0.11.0 lib/rom/factory.rb