Sha256: 2f365c9f299a5d11d77884cd3a046f942c07c3e060e46931d52ad505cafacd18

Contents?: true

Size: 1.12 KB

Versions: 21

Compression:

Stored size: 1.12 KB

Contents

module Fitting
  class Records
    class Documented
      class Request
        def initialize(tomogram_request, white_list)
          @tomogram_request = tomogram_request
          @white_list = white_list
        end

        def method
          @method ||= @tomogram_request.method
        end

        def path
          @path ||= @tomogram_request.path
        end

        def responses
          @responses ||= groups.map do |group|
            {
              'status' => group[0],
              'json_schemas' => group[1].map { |subgroup| subgroup['body'] }
            }
          end
        end

        def white
          @white ||= white?
        end

        private

        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

        def groups
          @groups ||= @tomogram_request.responses.group_by do |tomogram_response|
            tomogram_response['status']
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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