Class: LazyFixtures::FactoryGirl::AttributesManager
- Inherits:
-
Object
- Object
- LazyFixtures::FactoryGirl::AttributesManager
- Defined in:
- lib/lazy_fixtures/factory_girl/attributes_manager.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #delete_association_attributes ⇒ Object
- #each ⇒ Object
-
#initialize(object, options = {}) ⇒ AttributesManager
constructor
A new instance of AttributesManager.
- #stringify_attributes ⇒ Object
Constructor Details
#initialize(object, options = {}) ⇒ AttributesManager
Returns a new instance of AttributesManager.
8 9 10 11 12 13 |
# File 'lib/lazy_fixtures/factory_girl/attributes_manager.rb', line 8 def initialize(object, ={}) @object = object @attributes = @object.attributes = manipulate_attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/lazy_fixtures/factory_girl/attributes_manager.rb', line 5 def attributes @attributes end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
6 7 8 |
# File 'lib/lazy_fixtures/factory_girl/attributes_manager.rb', line 6 def object @object end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/lazy_fixtures/factory_girl/attributes_manager.rb', line 6 def end |
Instance Method Details
#delete_association_attributes ⇒ Object
27 28 29 |
# File 'lib/lazy_fixtures/factory_girl/attributes_manager.rb', line 27 def delete_association_attributes attributes.delete_if {|k,v| k =~ Regexp.new(/.+_id/) && !v.nil?} end |
#each ⇒ Object
15 16 17 |
# File 'lib/lazy_fixtures/factory_girl/attributes_manager.rb', line 15 def each attributes end |
#stringify_attributes ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/lazy_fixtures/factory_girl/attributes_manager.rb', line 19 def stringify_attributes attributes.map do |k,v| value = ValueMapper.new(object, k.to_s.dup, v).get_value key = ValueMapper.remove_encrypted(k.to_s.dup) " #{key} #{value}\n" end.join end |