Skip to content

Commit

Permalink
Be more explicit about where app_id is set and used
Browse files Browse the repository at this point in the history
  • Loading branch information
koppen committed Aug 20, 2012
1 parent b0ddc72 commit 2aa2d91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rbing.rb
Expand Up @@ -80,7 +80,7 @@ def method_missing(*args)

include HTTParty

attr_accessor :instance_options
attr_accessor :instance_options, :app_id
base_uri "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Web"

BASE_OPTIONS = [:version, :market, :adult, :query, :appid]
Expand Down Expand Up @@ -124,7 +124,8 @@ def search(source, query, options={})
# +options+ can contain values to be passed with each query.
#
def initialize(app_id=nil, options={})
@instance_options = options.merge(:AppId => (app_id || user_app_id))
@app_id = app_id
@instance_options = options
end
# constructs a query string for the given
# +query+ and the optional query +options+
Expand Down Expand Up @@ -172,9 +173,8 @@ def options_for(type, query, options={})

authentication_options = {:basic_auth => {
:username => '',
:password => "#{@instance_options[:AppId]}"
:password => (app_id || user_app_id)
}}
opts.delete(:AppId)
http_options = options[:http] || {}
http_options.merge!(authentication_options)
http_options.merge(:query => opts)
Expand Down

0 comments on commit 2aa2d91

Please sign in to comment.