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_ary ⇒ Object
:nodoc:.
- #to_s ⇒ Object (also: #inspect)
Instance Method Details
#_index ⇒ Object
Return the document ‘_index`
40 41 42 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 40 def _index @_index end |
#_type ⇒ Object
Return the document ‘_type`
46 47 48 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 46 def _type @_type end |
#_version ⇒ Object
Return the document ‘_version`
52 53 54 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 52 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`
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_ary ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/elasticsearch/persistence/model/base.rb', line 56 def to_ary # :nodoc: nil end |
#to_s ⇒ Object 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 |