Class: Elastomer::Client::RestApiSpec::RestApi::Url
- Inherits:
-
Object
- Object
- Elastomer::Client::RestApiSpec::RestApi::Url
- Defined in:
- lib/elastomer/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.
32 33 34 35 36 37 38 39 40 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 32 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.
30 31 32 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 30 def params @params end |
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
29 30 31 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 29 def parts @parts end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
27 28 29 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 27 def path @path end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
28 29 30 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 28 def paths @paths end |
Instance Method Details
#select_params(from:) ⇒ Object
50 51 52 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 50 def select_params(from:) from.select {|k,v| valid_param?(k)} end |
#select_parts(from:) ⇒ Object
42 43 44 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 42 def select_parts(from:) from.select {|k,v| valid_part?(k)} end |
#valid_param?(param) ⇒ Boolean
54 55 56 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 54 def valid_param?(param) @params_set.include?(param.to_s) end |
#valid_part?(part) ⇒ Boolean
46 47 48 |
# File 'lib/elastomer/client/rest_api_spec/rest_api.rb', line 46 def valid_part?(part) @parts_set.include?(part.to_s) end |