Module: Elasticsearch::Persistence::Model::Base::InstanceMethods
- Defined in:
- lib/elasticsearch/persistence/model/base.rb
Instance Method Summary collapse
-
#_index ⇒ Object
Return the document ‘_index`.
-
#_type ⇒ Object
Return the document ‘_type`.
-
#_version ⇒ Object
Return the document ‘_version`.
-
#attributes ⇒ Object
Return model attributes as a Hash, merging in the ‘id`.
-
#id ⇒ Object
(also: #_id)
Return the document ‘_id`.
-
#id=(value) ⇒ Object
(also: #_id=)
Set the document ‘_id`.
-
#initialize(attributes = {}) ⇒ Object
Model initializer sets the ‘@id` variable if passed.
- #to_s ⇒ Object (also: #inspect)
Instance Method Details
#_index ⇒ Object
Return the document ‘_index`
36 37 38 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 36 def _index @_index end |
#_type ⇒ Object
Return the document ‘_type`
42 43 44 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 42 def _type @_type end |
#_version ⇒ Object
Return the document ‘_version`
48 49 50 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 48 def _version @_version end |
#attributes ⇒ Object
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 |
#id ⇒ Object 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`
30 31 32 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 30 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_s ⇒ Object Also known as: inspect
52 53 54 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 52 def to_s "#<#{self.class} #{attributes.to_hash.inspect.gsub(/:(\w+)=>/, '\1: ')}>" end |