Module: Citier4::InstanceMethods::ForcedWriters

Defined in:
lib/citier4/instance_methods.rb

Instance Method Summary collapse

Instance Method Details

#force_attributes(new_attributes, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/citier4/instance_methods.rb', line 30

def force_attributes(new_attributes, options = {})
  # debugger
  # TODO  new_attributes = @attributes.merge(new_attributes) if options[:merge]
  new_attributes = self.attributes.merge(new_attributes) if options[:merge]
  
  # TODO @attributes = new_attributes
  self.attributes = new_attributes
  
  if options[:clear_caches] != false
    @aggregation_cache = {}
    @association_cache = {}
    @attributes_cache = {}
  end
end

#force_changed_attributes(new_changed_attributes, options = {}) ⇒ Object

TODO : Is is still usefull ? Can we remove by using ActiveRecord::Dirty ? see http://api.rubyonrails.org/classes/ActiveModel/Dirty.html



47
48
49
50
# File 'lib/citier4/instance_methods.rb', line 47

def force_changed_attributes(new_changed_attributes, options = {})
  new_changed_attributes = @attributes.merge(new_changed_attributes) if options[:merge]
  @changed_attributes = new_changed_attributes
end