Class: ElasticsearchRecord::Base

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Core, ModelSchema, Persistence, Querying
Defined in:
lib/elasticsearch_record/base.rb

Direct Known Subclasses

SchemaMigration

Instance Method Summary collapse

Instance Method Details

#_create_record(*args) ⇒ Object Originally defined in module Persistence

overwrite to provide a Elasticsearch version: Creates a record with values matching those of the instance attributes and returns its id.

#idObject Originally defined in module Core

overwrite to provide a Elasticsearch version of returning a 'primary_key' attribute. Elasticsearch uses the static +_id+ column as primary_key, but also supports an additional +id+ column. To provide functionality of returning the +id+ attribute, this method must also support it with enabled +delegate_id_attribute+.

Returns:

  • (Object)

#id=(value) ⇒ Object Originally defined in module Core

overwrite to provide a Elasticsearch version of setting a 'primary_key' attribute. Elasticsearch uses the static +_id+ column as primary_key, but also supports an additional +id+ column. To provide functionality of setting the +id+ attribute, this method must also support it with enabled +delegate_id_attribute+.

Parameters:

  • value (Object)

#id_wasObject Originally defined in module Core

overwrite to provide a Elasticsearch version of returning a 'primary_key' was attribute. Elasticsearch uses the static +_id+ column as primary_key, but also supports an additional +id+ column. To provide functionality of returning the +id_was+ attribute, this method must also support it with enabled +delegate_id_attribute+.

#read_attribute(attr_name, &block) ⇒ Object Originally defined in module Core

overwrite read_attribute method to read from the 'id'-attribute, if present. This methods does not check for +delegate_id_attribute+ flag! see @ ActiveRecord::AttributeMethods::Read#read_attribute

#undelegate_id_attribute_with(&block) ⇒ Object Originally defined in module Core

resets a possible active +delegate_id_attribute?+ to false during block execution. Unfortunately this is required, since a lot of rails-code forces 'accessors' on the primary_key-field through the +id+-getter & setter methods. This will then fail to set the doc-_id and instead set the +id+-attribute ...

#write_attribute(attr_name, value) ⇒ Object Originally defined in module Core

overwrite the write_attribute method to always write to the 'id'-attribute, if present. This methods does not check for +delegate_id_attribute+ flag! see @ ActiveRecord::AttributeMethods::Write#write_attribute