Class: FactoryGirlStepHelpers::HumanHashToAttributeHash

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_girl/step_definitions.rb

Defined Under Namespace

Classes: AssociationManager, AttributeStrategy, CreateAttributes, FindAttributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(human_hash, associations) ⇒ HumanHashToAttributeHash

Returns a new instance of HumanHashToAttributeHash.



9
10
11
12
# File 'lib/factory_girl/step_definitions.rb', line 9

def initialize(human_hash, associations)
  @human_hash   = human_hash
  @associations = associations
end

Instance Attribute Details

#associationsObject (readonly)

Returns the value of attribute associations.



7
8
9
# File 'lib/factory_girl/step_definitions.rb', line 7

def associations
  @associations
end

Instance Method Details

#attributes(strategy = CreateAttributes) ⇒ Object



14
15
16
17
18
19
# File 'lib/factory_girl/step_definitions.rb', line 14

def attributes(strategy = CreateAttributes)
  @human_hash.inject({}) do |attribute_hash, (human_key, value)|
    attributes = strategy.new(self, *process_key_value(human_key, value))
    attribute_hash.merge({ attributes.key => attributes.value })
  end
end