Skip to content

Commit

Permalink
Merge pull request theforeman#16 from tstrachota/resource_config
Browse files Browse the repository at this point in the history
Fixed config issues in Base#initialize
  • Loading branch information
mbacovsky committed Jun 20, 2013
2 parents 2f85608 + 81a3906 commit 434e90f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/foreman_api/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,22 @@ class Base
def initialize(config, options = {})
config = config.dup
self.logger = config.delete(:logger)
@client = RestClient::Resource.new(
config[:base_url],
{ :user => config[:username],
:password => config[:password],
:oauth => config[:oauth],
:headers => { :content_type => 'application/json',
:accept => "application/json;version=#{API_VERSION}" }
}.merge(options))

headers = {
:content_type => 'application/json',
:accept => "application/json;version=#{API_VERSION}"
}
headers.merge!(config[:headers]) unless config[:headers].nil?
headers.merge!(options.delete(:headers)) unless options[:headers].nil?

resource_config = {
:user => config[:username],
:password => config[:password],
:oauth => config[:oauth],
:headers => headers
}.merge(options)

@client = RestClient::Resource.new(config[:base_url], resource_config)
@config = config
end

Expand Down

0 comments on commit 434e90f

Please sign in to comment.