Class: Esse::HashDocument
- Inherits:
-
Document
- Object
- Document
- Esse::HashDocument
- Defined in:
- lib/esse/hash_document.rb
Constant Summary collapse
- META_KEYS =
%i[_id _type _routing routing].freeze
Instance Method Summary collapse
-
#id ⇒ String, Number
The document ID.
-
#initialize(object) ⇒ HashDocument
constructor
A new instance of HashDocument.
-
#meta ⇒ Hash
The document meta.
-
#routing ⇒ String?
The document routing.
-
#source ⇒ Hash
abstract
The document source.
-
#type ⇒ String?
The document type.
Constructor Details
#initialize(object) ⇒ HashDocument
7 8 9 10 |
# File 'lib/esse/hash_document.rb', line 7 def initialize(object) @object = object @options = {} end |
Instance Method Details
#id ⇒ String, Number
13 14 15 |
# File 'lib/esse/hash_document.rb', line 13 def id object['_id'] || object[:_id] || object['id'] || object[:id] end |
#meta ⇒ Hash
28 29 30 |
# File 'lib/esse/hash_document.rb', line 28 def {} end |
#routing ⇒ String?
23 24 25 |
# File 'lib/esse/hash_document.rb', line 23 def routing object['_routing'] || object[:_routing] || object['routing'] || object[:routing] end |
#source ⇒ Hash
This method is abstract.
Override this method to return the document source
Returns the document source.
34 35 36 |
# File 'lib/esse/hash_document.rb', line 34 def source object.reject { |key, _| META_KEYS.include?(key.to_sym) } end |
#type ⇒ String?
18 19 20 |
# File 'lib/esse/hash_document.rb', line 18 def type object['_type'] || object[:_type] end |