Class: Fitting::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(env_request, tomogram) ⇒ Request

Returns a new instance of Request.



5
6
7
8
9
10
11
# File 'lib/fitting/request.rb', line 5

def initialize(env_request, tomogram)
  @method = env_request.request_method
  @path = env_request.env['PATH_INFO'] || env_request.fullpath
  @body = env_request.env['action_dispatch.request.request_parameters']
  @schema = tomogram.find_request(method: @method, path: @path)
  self
end

Instance Method Details

#ignored?(ignore_list) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/fitting/request.rb', line 33

def ignored?(ignore_list)
  ignore_list.any? do |regexp|
    regexp.match(@path)
  end
end

#real_method_with_pathObject



17
18
19
# File 'lib/fitting/request.rb', line 17

def real_method_with_path
  "#{@method}\t#{@path}"
end

#routeObject



13
14
15
# File 'lib/fitting/request.rb', line 13

def route
  "#{@schema.method}\t#{@schema.path}"
end

#schemas_of_possible_responses(status:) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/fitting/request.rb', line 21

def schemas_of_possible_responses(status:)
  return nil unless @schema

  @schema.find_responses(status: status).map do |response|
    response['body']
  end
end

#within_prefix?(prefix) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/fitting/request.rb', line 29

def within_prefix?(prefix)
  @path.start_with?(prefix)
end