Sha256: 2b01610fab2ca0201d290671e0e5c7ff0c9fbe31c59f2ef6a21b3209cf5688f5

Contents?: true

Size: 884 Bytes

Versions: 25

Compression:

Stored size: 884 Bytes

Contents

require 'json-schema'

module Fitting
  class Request
    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

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

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

    def schemas_of_possible_responses(status:)
      return nil unless @schema

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

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

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
fitting-2.17.0 lib/fitting/request.rb
fitting-2.16.1 lib/fitting/request.rb
fitting-2.16.0 lib/fitting/request.rb
fitting-2.15.0 lib/fitting/request.rb
fitting-2.14.1 lib/fitting/request.rb
fitting-2.14.0 lib/fitting/request.rb
fitting-2.13.1 lib/fitting/request.rb
fitting-2.13.0 lib/fitting/request.rb
fitting-2.12.1 lib/fitting/request.rb
fitting-2.12.0 lib/fitting/request.rb
fitting-2.11.0 lib/fitting/request.rb
fitting-2.10.0 lib/fitting/request.rb
fitting-2.9.1 lib/fitting/request.rb
fitting-2.9.0 lib/fitting/request.rb
fitting-2.8.1 lib/fitting/request.rb
fitting-2.8.0 lib/fitting/request.rb
fitting-2.7.2 lib/fitting/request.rb
fitting-2.7.1 lib/fitting/request.rb
fitting-2.7.0 lib/fitting/request.rb
fitting-2.6.0 lib/fitting/request.rb