module Elastictastic::Dirty
Public Instance Methods
elasticsearch_doc=(doc)
click to toggle source
Calls superclass method
# File lib/elastictastic/dirty.rb, line 80 def elasticsearch_doc=(doc) super clean_attributes! end
save(options = {})
click to toggle source
Calls superclass method
# File lib/elastictastic/dirty.rb, line 75 def save(options = {}) super clean_attributes! end
write_attribute(field, value)
click to toggle source
Calls superclass method
# File lib/elastictastic/dirty.rb, line 53 def write_attribute(field, value) attribute_may_change!(field) { super } end
write_embed(field, value)
click to toggle source
Calls superclass method
# File lib/elastictastic/dirty.rb, line 57 def write_embed(field, value) attribute_may_change!(field) do if Array === value value.each do |el| el.nesting_document = self el.nesting_association = field end super(field, NestedCollectionProxy.new(self, field, value)) elsif value value.nesting_document = self value.nesting_association = field super else super end end end
Protected Instance Methods
attribute_may_change!(field) { || ... }
click to toggle source
# File lib/elastictastic/dirty.rb, line 94 def attribute_may_change!(field) attribute_will_change!(field) unless changed_attributes.key?(field) old_value = changed_attributes[field] yield attribute_not_changed!(field) if old_value == __send__(field) end
attribute_not_changed!(field)
click to toggle source
# File lib/elastictastic/dirty.rb, line 101 def attribute_not_changed!(field) changed_attributes.delete(field) end
clean_attributes!()
click to toggle source
# File lib/elastictastic/dirty.rb, line 87 def clean_attributes! changed_attributes.clear @_embeds.each_pair do |name, embedded| Util.call_or_map(embedded) { |doc| doc && doc.clean_attributes! } end end