Class: ElasticAdapter::Decoration::SuggestionResponse

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

Overview

Used to decorate responses from the elasticsearch suggestion api

Instance Attribute Summary collapse

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 Attribute Details

#countInteger (readonly)

the amount of suggestions


5
6
7
# File 'lib/elastic_adapter/decoration/suggestion_response.rb', line 5

def count
  @count
end

Instance Method Details

#alter_object(hash) ⇒ Hash

Builds a Hash with a smaller interface from the decorated response


13
14
15
16
17
# File 'lib/elastic_adapter/decoration/suggestion_response.rb', line 13

def alter_object(hash)
  new_hash = {}
  new_hash[:options] = hash[hash.keys[1]].first[:options]
  new_hash
end