Class: ElasticAdapter::Decoration::HitDecorator

Inherits:
Decorator
  • Object
show all
Defined in:
lib/elastic_adapter/decoration/hit_decorator.rb

Overview

Used to decorate responses from the elasticsearch get api or to decorate single hits returned from the elasticsearch search api

Instance Attribute Summary

Attributes inherited from Decorator

#original_object

Instance Method Summary collapse

Methods inherited from Decorator

#initialize, #object

Constructor Details

This class inherits a constructor from ElasticAdapter::Decoration::Decorator

Instance Method Details

#alter_object(hash) ⇒ Hash

Reduces the interface of a single hit

Parameters:

  • hash (Hash)

Returns:

  • (Hash)

14
15
16
17
18
19
20
21
22
# File 'lib/elastic_adapter/decoration/hit_decorator.rb', line 14

def alter_object(hash)
  new_hash = {}
  new_hash[:id] = hash[:id]
  hash[:source].each do |key, value|
    new_hash[key] = value
  end

  new_hash
end