Class: ElastomerClient::Client::RestApiSpec::RestApi::Url
- Inherits:
-
Object
- Object
- ElastomerClient::Client::RestApiSpec::RestApi::Url
- Defined in:
- lib/elastomer_client/client/rest_api_spec/rest_api.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
-
#initialize(path:, paths: [], parts: {}, params: {}) ⇒ Url
constructor
A new instance of Url.
- #select_params(from:) ⇒ Object
- #select_parts(from:) ⇒ Object
- #valid_param?(param) ⇒ Boolean
- #valid_part?(part) ⇒ Boolean
Constructor Details
#initialize(path:, paths: [], parts: {}, params: {}) ⇒ Url
Returns a new instance of Url.
34 35 36 37 38 39 40 41 42 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 34 def initialize(path:, paths: [], parts: {}, params: {}) @path = path @paths = Array(paths) @parts = parts @params = params @parts_set = Set.new(@parts.keys) @params_set = Set.new(@params.keys) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
32 33 34 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 32 def params @params end |
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
31 32 33 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 31 def parts @parts end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
29 30 31 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 29 def path @path end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
30 31 32 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 30 def paths @paths end |
Instance Method Details
#select_params(from:) ⇒ Object
52 53 54 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 52 def select_params(from:) from.select { |k, v| valid_param?(k) } end |
#select_parts(from:) ⇒ Object
44 45 46 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 44 def select_parts(from:) from.select { |k, v| valid_part?(k) } end |
#valid_param?(param) ⇒ Boolean
56 57 58 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 56 def valid_param?(param) @params_set.include?(param.to_s) end |
#valid_part?(part) ⇒ Boolean
48 49 50 |
# File 'lib/elastomer_client/client/rest_api_spec/rest_api.rb', line 48 def valid_part?(part) @parts_set.include?(part.to_s) end |