Module: Elasticsearch::Persistence::Model::Base::InstanceMethods

Defined in:
lib/elasticsearch/persistence/model/base.rb

Instance Method Summary collapse

Instance Method Details

#_indexObject

Return the document ‘_index`



40
41
42
# File 'lib/elasticsearch/persistence/model/base.rb', line 40

def _index
  @_index
end

#_typeObject

Return the document ‘_type`



46
47
48
# File 'lib/elasticsearch/persistence/model/base.rb', line 46

def _type
  @_type
end

#_versionObject

Return the document ‘_version`



52
53
54
# File 'lib/elasticsearch/persistence/model/base.rb', line 52

def _version
  @_version
end

#attributesObject

Return model attributes as a Hash, merging in the ‘id`



18
19
20
# File 'lib/elasticsearch/persistence/model/base.rb', line 18

def attributes
  super.merge id: id
end

#idObject Also known as: _id

Return the document ‘_id`



24
25
26
# File 'lib/elasticsearch/persistence/model/base.rb', line 24

def id
  @_id
end

#id=(value) ⇒ Object Also known as: _id=

Set the document ‘_id`



32
33
34
# File 'lib/elasticsearch/persistence/model/base.rb', line 32

def id=(value)
  @_id = value
end

#initialize(attributes = {}) ⇒ Object

Model initializer sets the ‘@id` variable if passed



11
12
13
14
# File 'lib/elasticsearch/persistence/model/base.rb', line 11

def initialize(attributes = {})
  @_id = attributes[:id] || attributes["id"]
  super
end

#to_aryObject

:nodoc:



56
57
58
# File 'lib/elasticsearch/persistence/model/base.rb', line 56

def to_ary # :nodoc:
  nil
end

#to_sObject Also known as: inspect



60
61
62
# File 'lib/elasticsearch/persistence/model/base.rb', line 60

def to_s
  "#<#{self.class} #{attributes.to_hash.inspect.gsub(/:(\w+)=>/, '\1: ')}>"
end