Sha256: 2191cfb66da000acb26ac33407db6f01dcdbf0be2901cbf4776c021aa1cab0d5

Contents?: true

Size: 543 Bytes

Versions: 6

Compression:

Stored size: 543 Bytes

Contents

# frozen_string_literal: true

module Grape
  module DSL
    module Headers
      # This method has four responsibilities:
      # 1. Set a specifc header value by key
      # 2. Retrieve a specifc header value by key
      # 3. Retrieve all headers that have been set
      # 4. Delete a specifc header key-value pair
      def header(key = nil, val = nil)
        if key
          val ? header[key.to_s] = val : header.delete(key.to_s)
        else
          @header ||= {}
        end
      end
      alias headers header
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
grape-2.0.0 lib/grape/dsl/headers.rb
grape-1.8.0 lib/grape/dsl/headers.rb
grape-1.7.1 lib/grape/dsl/headers.rb
grape-1.7.0 lib/grape/dsl/headers.rb
grape-1.6.2 lib/grape/dsl/headers.rb
grape-1.6.1 lib/grape/dsl/headers.rb