class FactoryGirlStepHelpers::HumanHashToAttributeHash
Attributes
associations[R]
Public Class Methods
new(human_hash, associations)
click to toggle source
# File lib/factory_girl/step_definitions.rb, line 9 def initialize(human_hash, associations) @human_hash = human_hash @associations = associations end
Public Instance Methods
attributes(strategy = CreateAttributes)
click to toggle source
# 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
Private Instance Methods
process_key_value(key, value)
click to toggle source
# File lib/factory_girl/step_definitions.rb, line 23 def process_key_value(key, value) value = value.strip if value.is_a?(String) [key.downcase.gsub(' ', '_').to_sym, value] end