Class: FactoryGirl::DeclarationList

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

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ DeclarationList

Returns a new instance of DeclarationList.



5
6
7
8
9
# File 'lib/factory_girl/declaration_list.rb', line 5

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

Instance Method Details

#attribute_listObject



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

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

#declare_attribute(declaration) ⇒ Object



11
12
13
14
15
16
# File 'lib/factory_girl/declaration_list.rb', line 11

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

  @declarations << declaration
  declaration
end

#each(&block) ⇒ Object



30
31
32
# File 'lib/factory_girl/declaration_list.rb', line 30

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

#overridableObject



18
19
20
# File 'lib/factory_girl/declaration_list.rb', line 18

def overridable
  @overridable = true
end