Class: Callapi::Call::RequestMetadata

Inherits:
Struct
  • Object
show all
Defined in:
lib/callapi/call/request_metadata.rb

Constant Summary collapse

HTTP_METHODS =
%w(GET POST PUT PATCH DELETE)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



1
2
3
# File 'lib/callapi/call/request_metadata.rb', line 1

def context
  @context
end

Instance Method Details

#request_methodObject



4
5
6
7
8
# File 'lib/callapi/call/request_metadata.rb', line 4

def request_method
  http_method = namespace_with_http_method
  raise Callapi::UnknownHttpMethodError unless http_method
  http_method.downcase.to_sym
end

#request_pathObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/callapi/call/request_metadata.rb', line 10

def request_path
  return @request_path if @request_path

  @request_path = request_path_without_replaced_param_keys
  param_keys_to_replace.each do |param_key|
    param_value = context.params[param_key.to_sym] || raise_missing_param_error
    @request_path.sub!(param_key + '_param', param_value.to_s)
  end
  @request_path
end