class Fitting::Records::Documented::Request

Public Class Methods

new(tomogram_request, white_list) click to toggle source
# File lib/fitting/records/documented/request.rb, line 5
def initialize(tomogram_request, white_list)
  @tomogram_request = tomogram_request
  @white_list = white_list
end

Public Instance Methods

method() click to toggle source
# File lib/fitting/records/documented/request.rb, line 10
def method
  @method ||= @tomogram_request.method
end
path() click to toggle source
# File lib/fitting/records/documented/request.rb, line 14
def path
  @path ||= @tomogram_request.path
end
responses() click to toggle source
# File lib/fitting/records/documented/request.rb, line 18
def responses
  @responses ||= groups.map do |group|
    {
      'status' => group[0],
      'json_schemas' => group[1].map { |subgroup| subgroup['body'] }
    }
  end
end
white() click to toggle source
# File lib/fitting/records/documented/request.rb, line 27
def white
  @white ||= white?
end

Private Instance Methods

groups() click to toggle source
# File lib/fitting/records/documented/request.rb, line 41
def groups
  @groups ||= @tomogram_request.responses.group_by do |tomogram_response|
    tomogram_response['status']
  end
end
white?() click to toggle source
# File lib/fitting/records/documented/request.rb, line 33
def white?
  return true if @white_list == nil
  return false if @white_list[path.to_s] == nil
  return true if @white_list[path.to_s] == []
  return true if @white_list[path.to_s].include?(method)
  false
end