Sha256: 1ff85eb23d0ce56546a7d044ad7b3c177f8f2ceec9f7fa8326286fc4198f2d16

Contents?: true

Size: 437 Bytes

Versions: 12

Compression:

Stored size: 437 Bytes

Contents

module Rack
  class API
    class Response
      attr_reader :options

      def initialize(options)
        @options = options
      end

      def to_rack
        return options.to_rack if options.respond_to?(:to_rack)

        [
          options.fetch(:status, 403),
          {"Content-Type" => "text/plain"}.merge(options.fetch(:headers, {})),
          [options.fetch(:message, "Forbidden")]
        ]
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rack-api-1.1.0 lib/rack/api/response.rb
rack-api-1.0.2 lib/rack/api/response.rb
rack-api-1.0.1 lib/rack/api/response.rb
rack-api-1.0.0 lib/rack/api/response.rb
rack-api-0.3.1 lib/rack/api/response.rb
rack-api-0.3.0 lib/rack/api/response.rb
rack-api-0.2.2 lib/rack/api/response.rb
rack-api-0.2.1 lib/rack/api/response.rb
rack-api-0.2.0 lib/rack/api/response.rb
rack-api-0.1.2 lib/rack/api/response.rb
rack-api-0.1.1 lib/rack/api/response.rb
rack-api-0.1.0 lib/rack/api/response.rb