def define(spec, **opts, &block)
      name, parent = spec.is_a?(Hash) ? spec.flatten(1) : spec

      if registry.key?(name)
        raise ArgumentError, "#{name.inspect} factory has been already defined"
      end

      builder =
        if parent
          extend_builder(name, registry[parent], &block)
        else
          relation_name = opts.fetch(:relation) { infer_relation(name) }
          relation = rom.relations[relation_name]
          DSL.new(name, relation: relation.struct_namespace(struct_namespace), factories: self, &block).call
        end

      registry[name] = builder
    end
def define(spec, **opts, &block)
      name, parent = spec.is_a?(Hash) ? spec.flatten(1) : spec

      if registry.key?(name)
        raise ArgumentError, "#{name.inspect} factory has been already defined"
      end

      builder =
        if parent
          extend_builder(name, registry[parent], &block)
        else
          relation_name = opts.fetch(:relation) { infer_relation(name) }
          relation = rom.relations[relation_name]
          DSL.new(name, relation: relation.struct_namespace(struct_namespace), factories: self, &block).call
        end

      registry[name] = builder
    end
Define a new builder

 @example a simple builder
   MyFactory.define(:user) do |f|
     f.name "Jane"
     f.email "jane@doe.org"
   end

 @example a builder using auto-generated fake values
   MyFactory.define(:user) do |f|
     f.name { fake(:name) }
     f.email { fake(:internet, :email) }
   end

 @example a builder using sequenced values
   MyFactory.define(:user) do |f|
     f.sequence(:name) { |n| "user-#{n}" }
   end

 @example a builder using values from other attribute(s)
   MyFactory.define(:user) do |f|
     f.name "Jane"
     f.email { |name| "#{name.downcase}@rom-rb.org" }
   end

 @example a builder with "belongs-to" association
   MyFactory.define(:group) do |f|
     f.name "Admins"
   end

   MyFactory.define(:user) do |f|
     f.name "Jane"
     f.association(:group)
   end

 @example a builder with "has-many" association
   MyFactory.define(:group) do |f|
     f.name "Admins"
     f.association(:users, count: 2)
   end

   MyFactory.define(:user) do |f|
     f.sequence(:name) { |n| "user-#{n}" }
   end

 @example a builder which extends another builder
   MyFactory.define(:user) do |f|
     f.name "Jane"
     f.admin false
   end

   MyFactory.define(admin: :user) do |f|
     f.admin true
   end

 @param [Symbol, Hash<Symbol=>Symbol>] spec Builder identifier, can point to a parent builder too
 @param [Hash] opts Additional options
 @option opts [Symbol] relation An optional relation name (defaults to pluralized builder name)

 @return [ROM::Factory::Builder]

 @api public