lib/authlogic_connect/oauth/tokens/oauth_token.rb~ in authlogic-connect-andrewacove-0.5.5 vs lib/authlogic_connect/oauth/tokens/oauth_token.rb~ in authlogic-connect-andrewacove-0.5.6

- old
+ new

@@ -16,19 +16,27 @@ self.class.oauth_version end def get(path, options = {}) config_options = self.class.send(:credentials)[:options] - api_version = config_options[:api_version] unless config_options.nil? + unless config_options.nil? + api_version = config_options[:api_version] + user_agent = config_options[:user_agent] + end path.insert(0, "/#{api_version}") unless api_version.nil? + options.reverse_merge! {"User-Agent" => user_agent} unless user_agent.nil? client.get(path, options) end def post(path, body='', headers ={}) config_options = self.class.send(:credentials)[:options] - api_version = config_options[:api_version] unless config_options.nil? + unless config_options.nil? + api_version = config_options[:api_version] + user_agent = config_options[:user_agent] + end path.insert(0, "/#{api_version}") unless api_version.nil? + headers.reverse_merge! {"User-Agent" => user_agent} unless user_agent.nil? client.post(path, body, headers) end class << self @@ -55,19 +63,16 @@ def oauth_key @oauth_key end - def reset_consumer! + + def consumer if oauth_version == 1.0 - @consumer = OAuth::Consumer.new(credentials[:key], credentials[:secret], config.merge(credentials[:options] || {})) + OAuth::Consumer.new(credentials[:key], credentials[:secret], config.merge(credentials[:options] || {})) else - @consumer = OAuth2::Client.new(credentials[:key], credentials[:secret], config.merge(credentials[:options] || {})) + OAuth2::Client.new(credentials[:key], credentials[:secret], config.merge(credentials[:options] || {})) end - end - - def consumer - @consumer || reset_consumer! end # if we're lucky we can find it by the token. def find_by_key_or_token(key, token, options = {}) result = self.find_by_key(key, options) unless key.nil?