module Tire::Model::Persistence::Storage::InstanceMethods

Public Instance Methods

destroy() click to toggle source
# File lib/tire/model/persistence/storage.rb, line 68
def destroy
  run_callbacks :destroy do
    @destroyed = true
    response = update_index
    ! response.nil?
  end
end
destroyed?() click to toggle source
# File lib/tire/model/persistence/storage.rb, line 76
def destroyed?   ;  !!@destroyed;       end
new_record?() click to toggle source
# File lib/tire/model/persistence/storage.rb, line 78
def new_record?  ;  !persisted?;        end
persisted?() click to toggle source
# File lib/tire/model/persistence/storage.rb, line 77
def persisted?   ;  !!id && !!_version; end
save() click to toggle source
# File lib/tire/model/persistence/storage.rb, line 60
def save
  return false unless valid?
  run_callbacks :save do
    response = update_index
    !! response['ok']
  end
end
update_attribute(name, value) click to toggle source
# File lib/tire/model/persistence/storage.rb, line 33
def update_attribute(name, value)
  __update_attributes name => value
  save
end
update_attributes(attributes={}) click to toggle source
# File lib/tire/model/persistence/storage.rb, line 38
def update_attributes(attributes={})
  __update_attributes attributes
  save
end
update_index() click to toggle source
# File lib/tire/model/persistence/storage.rb, line 43
def update_index
  run_callbacks :update_elasticsearch_index do
    if destroyed?
      response = index.remove self
    else
      if response = index.store( self, {:percolate => percolator} )
        self.id     ||= response['_id']
        self._index   = response['_index']
        self._type    = response['_type']
        self._version = response['_version']
        self.matches  = response['matches']
      end
    end
    response
  end
end