Class: SearchmetricsClient::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/searchmetrics_client/query.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, params = {}) ⇒ Query

Returns a new instance of Query.

[View source]

11
12
13
14
15
# File 'lib/searchmetrics_client/query.rb', line 11

def initialize(endpoint, params = {})
  @endpoint = endpoint
  @params   = params
  @query    = build_query
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.


3
4
5
# File 'lib/searchmetrics_client/query.rb', line 3

def endpoint
  @endpoint
end

#paramsObject

Returns the value of attribute params.


3
4
5
# File 'lib/searchmetrics_client/query.rb', line 3

def params
  @params
end

#queryObject

Returns the value of attribute query.


3
4
5
# File 'lib/searchmetrics_client/query.rb', line 3

def query
  @query
end

Class Method Details

.from_hash(hash) ⇒ Object

[View source]

5
6
7
8
9
# File 'lib/searchmetrics_client/query.rb', line 5

def self.from_hash(hash)
  endpoint = hash.fetch(:endpoint)
  params   = hash.fetch(:params, {})
  new(endpoint, params)
end

Instance Method Details

#to_hObject

[View source]

17
18
19
20
21
# File 'lib/searchmetrics_client/query.rb', line 17

def to_h
  hash = { endpoint: endpoint }
  hash[:params] = params unless params.empty?
  hash
end