Class: LazyFixtures::AttributesManager
- Inherits:
-
Object
- Object
- LazyFixtures::AttributesManager
- Defined in:
- lib/lazy_fixtures/attributes_manager.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #add_attributes ⇒ Object
- #delete_association_attributes(method) ⇒ Object
- #each ⇒ Object
-
#initialize(object, options = {}) ⇒ AttributesManager
constructor
A new instance of AttributesManager.
- #manipulate_attributes ⇒ Object
Constructor Details
#initialize(object, options = {}) ⇒ AttributesManager
Returns a new instance of AttributesManager.
6 7 8 9 10 |
# File 'lib/lazy_fixtures/attributes_manager.rb', line 6 def initialize(object, ={}) @object = object @attributes = @object.attributes @options = end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/lazy_fixtures/attributes_manager.rb', line 4 def attributes @attributes end |
Instance Method Details
#add_attributes ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/lazy_fixtures/attributes_manager.rb', line 12 def add_attributes return_value = '' attributes.each do |k,v| value = ValueMapper.new(@object, k.to_s.dup, v).map_values key = ValueMapper.remove_encrypted(k.to_s.dup) return_value += " #{key} #{value}\n" end return_value end |
#delete_association_attributes(method) ⇒ Object
28 29 30 |
# File 'lib/lazy_fixtures/attributes_manager.rb', line 28 def delete_association_attributes(method) attributes.delete_if {|k,v| k =~ Regexp.new(method) && !v.nil?} end |
#each ⇒ Object
32 33 34 |
# File 'lib/lazy_fixtures/attributes_manager.rb', line 32 def each attributes end |
#manipulate_attributes ⇒ Object
22 23 24 25 26 |
# File 'lib/lazy_fixtures/attributes_manager.rb', line 22 def manipulate_attributes @options[:skip_attr].each { |x| attributes.delete(x)} unless @options[:skip_attr].empty? attributes.merge!(@options[:change_attr]) unless @options[:change_attr].empty? attributes end |