Permalink
Browse files

Be more explicit about where app_id is set and used

  • Loading branch information...
1 parent b0ddc72 commit 2aa2d91e40eaf0063a9c6d535a74210bbbd6ee4f @koppen committed Aug 20, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/rbing.rb
View
@@ -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]
@@ -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+
@@ -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)

0 comments on commit 2aa2d91

Please sign in to comment.