Module: Elastictastic::Dirty

Extended by:
ActiveSupport::Concern
Defined in:
lib/elastictastic/dirty.rb

Defined Under Namespace

Modules: ClassMethods, EmbeddedDocumentMethods Classes: NestedCollectionProxy

Instance Method Summary collapse

Instance Method Details

#elasticsearch_doc=(doc) ⇒ Object



80
81
82
83
# File 'lib/elastictastic/dirty.rb', line 80

def elasticsearch_doc=(doc)
  super
  clean_attributes!
end

#save(options = {}) ⇒ Object



75
76
77
78
# File 'lib/elastictastic/dirty.rb', line 75

def save(options = {})
  super
  clean_attributes!
end

#write_attribute(field, value) ⇒ Object



53
54
55
# File 'lib/elastictastic/dirty.rb', line 53

def write_attribute(field, value)
  attribute_may_change!(field) { super }
end

#write_embed(field, value) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# 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