Class: FactoryGirl::AttributeList
- Inherits:
-
Object
- Object
- FactoryGirl::AttributeList
- Includes:
- Enumerable
- Defined in:
- lib/factory_girl/attribute_list.rb
Instance Method Summary collapse
- #apply_attributes(attributes_to_apply) ⇒ Object
- #associations ⇒ Object
- #define_attribute(attribute) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(name = nil) ⇒ AttributeList
constructor
A new instance of AttributeList.
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 |
#associations ⇒ Object
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 |