Sha256: a682d97aae74cfdbf3a3a1cb264036b75f1c1c27ce372e265bb4d85641d1ed20

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/hash/deep_merge'
module Axel
  class RequestOptions
    attr_accessor :given_options
    attr_accessor :default_options

    def initialize(default_options = {}, given_options)
      self.default_options = (default_options || {})
      self.given_options = (given_options || {}).with_indifferent_access
    end

    def compiled
      default_request_options.
        dup.
        deep_merge!(default_options).
        deep_merge!(given_options).
        with_indifferent_access
    end

    def default_request_options
      { headers: { 'Content-Type' => 'application/json' } }.with_indifferent_access
    end
    private :default_request_options
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axel-0.0.1 lib/axel/request_options.rb