module Elasticsearch::Persistence::Repository::Serialize
Provide serialization and deserialization between Ruby objects and Elasticsearch
documents
Override these methods in your repository class to customize the logic.
Public Instance Methods
deserialize(document)
click to toggle source
Deserialize the document retrieved from Elasticsearch
into a Ruby object
Use the ‘klass` property, if defined, otherwise try to get the class from the document’s ‘_type`.
# File lib/elasticsearch/persistence/repository/serialize.rb, line 23 def deserialize(document) _klass = klass || __get_klass_from_type(document['_type']) _klass.new document['_source'] || document['fields'] end
serialize(document)
click to toggle source
Serialize
the object for storing it in Elasticsearch
In the default implementation, call the ‘to_hash` method on the passed object.
# File lib/elasticsearch/persistence/repository/serialize.rb, line 15 def serialize(document) document.to_hash end