Class: Hibp::Query
- Inherits:
-
Object
- Object
- Hibp::Query
- Defined in:
- lib/hibp/query.rb
Overview
Hibp::Query
Used to build and execute request to the HIBP API
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#fetch ⇒ Array<String>, ...
Perform query execution(data fetching).
-
#initialize(endpoint:, headers: {}, parser: Parsers::Json.new) ⇒ Query
constructor
A new instance of Query.
-
#where(filters = {}) ⇒ Hibp::Query
Apply query filtration.
Constructor Details
#initialize(endpoint:, headers: {}, parser: Parsers::Json.new) ⇒ Query
Returns a new instance of Query.
20 21 22 23 24 25 26 |
# File 'lib/hibp/query.rb', line 20 def initialize(endpoint:, headers: {}, parser: Parsers::Json.new) @endpoint = endpoint @headers = headers @parser = parser @query_params = {} end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
9 10 11 |
# File 'lib/hibp/query.rb', line 9 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/hibp/query.rb', line 9 def headers @headers end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
9 10 11 |
# File 'lib/hibp/query.rb', line 9 def parser @parser end |
Instance Method Details
#fetch ⇒ Array<String>, ...
Perform query execution(data fetching)
]
63 64 65 |
# File 'lib/hibp/query.rb', line 63 def fetch confugure_request.get(headers: @headers, params: @query_params) end |
#where(filters = {}) ⇒ Hibp::Query
Apply query filtration
48 49 50 51 52 |
# File 'lib/hibp/query.rb', line 48 def where(filters = {}) tap do @query_params.merge!(convert_filters(filters)) end end |