Class: Elastomer::Client::RestApiSpec::RestApi::Url

Inherits:
Object
  • Object
show all
Defined in:
lib/elastomer/client/rest_api_spec/rest_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#paramsObject (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

#partsObject (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

#pathObject (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

#pathsObject (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

Returns:

  • (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

Returns:

  • (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