Sha256: b225317597314a3b67808de6571740eab746ca5405d9c59d4f624dfae982980f

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

module JsonApiClient
  module Helpers
    module CustomHeaders
      extend ActiveSupport::Concern

      module ClassMethods
        def with_headers(headers)
          self.custom_headers = headers
          yield
        ensure
          self.custom_headers = {}
        end

        def custom_headers
          header_store
        end

        def custom_headers=(headers)
          header_store.replace(headers)
        end

        protected

        def header_store
          Thread.current["json_api_client-#{resource_name}"] ||= {}
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_api_client-1.0.0.beta5 lib/json_api_client/helpers/custom_headers.rb