Class: Fugle::HTTP::Query Private
- Inherits:
-
Object
- Object
- Fugle::HTTP::Query
- Defined in:
- lib/fugle/http/query.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
HTTP Query String
Defined Under Namespace
Classes: MissingParameterError
Instance Method Summary collapse
- #all_required? ⇒ Boolean private
-
#initialize(query, parameters) ⇒ Query
constructor
private
Create new query.
- #to_h ⇒ Object private
- #to_s ⇒ Object private
-
#verify! ⇒ Object
private
Verify parameters.
Constructor Details
#initialize(query, parameters) ⇒ Query
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create new query
21 22 23 24 25 26 |
# File 'lib/fugle/http/query.rb', line 21 def initialize(query, parameters) @query = query @parameters = parameters verify! end |
Instance Method Details
#all_required? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 |
# File 'lib/fugle/http/query.rb', line 40 def all_required? @parameters .requires .reduce(true) do |prev, curr| @query[curr[:name]] && prev end end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 53 54 55 56 57 |
# File 'lib/fugle/http/query.rb', line 50 def to_h @query .map do |name, value| as = @parameters[name]&.fetch(:alias, nil) [as || name, value] end .to_h end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/fugle/http/query.rb', line 61 def to_s URI.encode_www_form(to_h) end |
#verify! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Verify parameters
32 33 34 35 36 |
# File 'lib/fugle/http/query.rb', line 32 def verify! raise MissingParameterError unless all_required? true end |