Class: FactoryGirl::AttributeList

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

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ AttributeList

Returns a new instance of AttributeList.



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

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

Instance Method Details

#apply_attributes(attributes_to_apply) ⇒ Object



25
26
27
# File 'lib/factory_girl/attribute_list.rb', line 25

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

#associationsObject



21
22
23
# File 'lib/factory_girl/attribute_list.rb', line 21

def associations
  @attributes.select(&:association?)
end

#define_attribute(attribute) ⇒ Object



10
11
12
13
14
15
# File 'lib/factory_girl/attribute_list.rb', line 10

def define_attribute(attribute)
  ensure_attribute_not_self_referencing! attribute
  ensure_attribute_not_defined! attribute

  add_attribute attribute
end

#each(&block) ⇒ Object



17
18
19
# File 'lib/factory_girl/attribute_list.rb', line 17

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