Class: ResourceKit::EndpointResolver
- Inherits:
-
Object
- Object
- ResourceKit::EndpointResolver
- Defined in:
- lib/resource_kit/endpoint_resolver.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#query_param_keys ⇒ Object
readonly
Returns the value of attribute query_param_keys.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ EndpointResolver
constructor
A new instance of EndpointResolver.
- #resolve(values = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ EndpointResolver
Returns a new instance of EndpointResolver.
7 8 9 10 |
# File 'lib/resource_kit/endpoint_resolver.rb', line 7 def initialize( = {}) @path = [:path] @query_param_keys = [:query_param_keys] || [] end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/resource_kit/endpoint_resolver.rb', line 5 def path @path end |
#query_param_keys ⇒ Object (readonly)
Returns the value of attribute query_param_keys.
5 6 7 |
# File 'lib/resource_kit/endpoint_resolver.rb', line 5 def query_param_keys @query_param_keys end |
Instance Method Details
#resolve(values = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/resource_kit/endpoint_resolver.rb', line 12 def resolve(values = {}) uri = Addressable::URI.parse(path) new_path = generated_path(uri.path, values) uri.path = normalized_path_components(new_path) uri.query = append_query_values(uri, values) unless query_param_keys.empty? uri.to_s end |