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.
28 29 30 31 32 |
# File 'lib/factory_girl/step_definitions.rb', line 28 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
34 35 36 |
# File 'lib/factory_girl/step_definitions.rb', line 34 def association @human_hash_to_attributes_hash.associations.detect {|association| association.name == @key } end |
#association_instance ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/factory_girl/step_definitions.rb', line 38 def association_instance return unless association if attributes_hash = nested_attribute_hash factory.build_class.find(:first, :conditions => attributes_hash.attributes(FindAttributes)) or FactoryGirl.create(association.factory, attributes_hash.attributes) end end |