class FactoryBot::AttributeList

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/factory_bot/attribute_list.rbs

class FactoryBot::AttributeList
  def add_attribute: (FactoryBot::Attribute::Dynamic attribute) -> FactoryBot::Attribute::Dynamic
  def apply_attributes: ((Array[FactoryBot::Attribute::Dynamic] | Array[]) attributes_to_apply) -> untyped
  def attribute_defined?: (Symbol attribute_name) -> false
  def define_attribute: (FactoryBot::Attribute::Dynamic attribute) -> FactoryBot::Attribute::Dynamic
  def each: () -> untyped
  def ensure_attribute_not_defined!: (FactoryBot::Attribute::Dynamic attribute) -> nil
  def ensure_attribute_not_self_referencing!: (FactoryBot::Attribute::Dynamic attribute) -> nil
  def ignored: () -> FactoryBot::AttributeList
  def initialize: (?nil name, ?(Array[FactoryBot::Attribute::Dynamic] | Array[]) attributes) -> void
  def names: () -> untyped
  def non_ignored: () -> FactoryBot::AttributeList
end

@api private

def add_attribute(attribute)

Experimental RBS support (using type sampling data from the type_fusion project).

def add_attribute: (FactoryBot::Attribute::Dynamic attribute) -> FactoryBot::Attribute::Dynamic

This signature was generated using 46 samples from 3 applications.

def add_attribute(attribute)
  @attributes << attribute
  attribute
end

def apply_attributes(attributes_to_apply)

Experimental RBS support (using type sampling data from the type_fusion project).

def apply_attributes: ((FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | ) attributes_to_apply) -> untyped

This signature was generated using 3 samples from 2 applications.

def apply_attributes(attributes_to_apply)
  attributes_to_apply.each { |attribute| add_attribute(attribute) }
end

def associations

def associations
  AttributeList.new(@name, select(&:association?))
end

def attribute_defined?(attribute_name)

Experimental RBS support (using type sampling data from the type_fusion project).

def attribute_defined?: (Symbol attribute_name) -> false

This signature was generated using 6 samples from 1 application.

def attribute_defined?(attribute_name)
  @attributes.any? do |attribute|
    attribute.name == attribute_name
  end
end

def define_attribute(attribute)

Experimental RBS support (using type sampling data from the type_fusion project).

def define_attribute: (FactoryBot::Attribute::Dynamic attribute) -> FactoryBot::Attribute::Dynamic

This signature was generated using 3 samples from 1 application.

def define_attribute(attribute)
  ensure_attribute_not_self_referencing! attribute
  ensure_attribute_not_defined! attribute
  add_attribute attribute
end

def each(&block)

Experimental RBS support (using type sampling data from the type_fusion project).

def each: () -> untyped

This signature was generated using 24 samples from 2 applications.

def each(&block)
  @attributes.each(&block)
end

def ensure_attribute_not_defined!(attribute)

Experimental RBS support (using type sampling data from the type_fusion project).

def ensure_attribute_not_defined!: (FactoryBot::Attribute::Dynamic attribute) -> nil

This signature was generated using 7 samples from 1 application.

def ensure_attribute_not_defined!(attribute)
  if attribute_defined?(attribute.name)
    raise AttributeDefinitionError, "Attribute already defined: #{attribute.name}"
  end
end

def ensure_attribute_not_self_referencing!(attribute)

Experimental RBS support (using type sampling data from the type_fusion project).

def ensure_attribute_not_self_referencing!: (FactoryBot::Attribute::Dynamic attribute) -> nil

This signature was generated using 4 samples from 1 application.

def ensure_attribute_not_self_referencing!(attribute)
  if attribute.respond_to?(:factory) && attribute.factory == @name
    message = "Self-referencing association '#{attribute.name}' in '#{attribute.factory}'"
    raise AssociationDefinitionError, message
  end
end

def ignored

Experimental RBS support (using type sampling data from the type_fusion project).

def ignored: () -> FactoryBot::AttributeList

This signature was generated using 2 samples from 1 application.

def ignored
  AttributeList.new(@name, select(&:ignored))
end

def initialize(name = nil, attributes = [])

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize: (?nil name, ?(FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | FactoryBot::Attribute::Dynamic | ) attributes) -> void

This signature was generated using 8 samples from 2 applications.

def initialize(name = nil, attributes = [])
  @name = name
  @attributes = attributes
end

def names

Experimental RBS support (using type sampling data from the type_fusion project).

def names: () -> untyped

This signature was generated using 7 samples from 3 applications.

def names
  map(&:name)
end

def non_ignored

Experimental RBS support (using type sampling data from the type_fusion project).

def non_ignored: () -> FactoryBot::AttributeList

This signature was generated using 5 samples from 2 applications.

def non_ignored
  AttributeList.new(@name, reject(&:ignored))
end