Class: FactoryBot::DeclarationList Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/factory_bot/declaration_list.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ DeclarationList

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DeclarationList.



6
7
8
9
10
# File 'lib/factory_bot/declaration_list.rb', line 6

def initialize(name = nil)
  @declarations = []
  @name = name
  @overridable = false
end

Instance Method Details

#attributesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
# File 'lib/factory_bot/declaration_list.rb', line 23

def attributes
  @attributes ||= AttributeList.new(@name).tap do |list|
    to_attributes.each do |attribute|
      list.define_attribute(attribute)
    end
  end
end

#declare_attribute(declaration) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
# File 'lib/factory_bot/declaration_list.rb', line 12

def declare_attribute(declaration)
  delete_declaration(declaration) if overridable?

  @declarations << declaration
  declaration
end

#each(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/factory_bot/declaration_list.rb', line 31

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

#overridableObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/factory_bot/declaration_list.rb', line 19

def overridable
  @overridable = true
end