Class: FactoryGirlStepHelpers::HumanHashToAttributeHash::AssociationManager
- Inherits:
-
Object
- Object
- FactoryGirlStepHelpers::HumanHashToAttributeHash::AssociationManager
- Defined in:
- lib/factory_girl/step_definitions.rb
Instance Method Summary collapse
- #association ⇒ Object
- #association_instance ⇒ Object
-
#initialize(human_hash_to_attributes_hash, key, value) ⇒ AssociationManager
constructor
A new instance of AssociationManager.
Constructor Details
#initialize(human_hash_to_attributes_hash, key, value) ⇒ AssociationManager
Returns a new instance of AssociationManager.
29 30 31 32 33 |
# File 'lib/factory_girl/step_definitions.rb', line 29 def initialize(human_hash_to_attributes_hash, key, value) @human_hash_to_attributes_hash = human_hash_to_attributes_hash @key = key @value = value end |
Instance Method Details
#association ⇒ Object
35 36 37 |
# File 'lib/factory_girl/step_definitions.rb', line 35 def association @human_hash_to_attributes_hash.associations.detect {|association| association.name == @key } end |
#association_instance ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/factory_girl/step_definitions.rb', line 39 def association_instance return unless association if attributes_hash = nested_attribute_hash factory.build_class.first(:conditions => attributes_hash.attributes(FindAttributes)) or FactoryGirl.create(association.factory, attributes_hash.attributes) end end |