class ROM::Factory::Structs

In-memory builder API

@api public

Attributes

registry[R]

@!attribute [r] registry

@return [Hash<Symbol=>Builder>]
struct_namespace[R]

@!attribute [r] struct_namespace

@return [Module]

Public Class Methods

new(registry, struct_namespace) click to toggle source

@api private

# File lib/rom/factory/factories.rb, line 25
def initialize(registry, struct_namespace)
  @registry = registry
  @struct_namespace = struct_namespace
end

Public Instance Methods

[](name, *traits, **attrs) click to toggle source

Build an in-memory struct

@example create a struct with default attributes

MyFactory[:user]

@example create a struct with some attributes overridden

MyFactory.structs[:user, name: "Jane"]

@param [Symbol] name The name of the registered factory @param [Hash] attrs An optional hash with attributes

@return [ROM::Struct]

@api public

# File lib/rom/factory/factories.rb, line 44
def [](name, *traits, **attrs)
  registry[name].struct_namespace(struct_namespace).create(*traits, attrs)
end