Browse files

Make sure headers are properly cleared and set.

  • Loading branch information...
1 parent f46a5ba commit f6b03f2e4e0ee0b2b3e1438176a303eb3387e24e @redronin redronin committed Mar 30, 2012
Showing with 19 additions and 13 deletions.
  1. +19 −13 lib/shopify_api/resources/base.rb
View
32 lib/shopify_api/resources/base.rb
@@ -8,21 +8,27 @@ class Base < ActiveResource::Base
"ActiveResource/#{ActiveResource::VERSION::STRING}",
"Ruby/#{RUBY_VERSION}"].join(' ')
+ class << self
+ def headers
+ if defined?(@headers)
+ @headers
+ elsif superclass != Object && superclass.headers
+ superclass.headers
+ else
+ @headers ||= {}
+ end
+ end
+ def activate_session(session)
+ self.site = session.site
+ self.headers.merge!('X-Shopify-Access-Token' => session.token)
+ end
- def self.activate_session(session)
- self.site = session.site
- ActiveResource::Base.site = session.site
- self.headers.merge!('X-Shopify-Access-Token' => session.token)
- ActiveResource::Base.headers.merge!('X-Shopify-Access-Token' => session.token)
- end
-
- def self.clear_session
- self.site = nil
- ActiveResource::Base.site = nil
- self.headers.delete('X-Shopify-Access-Token')
- ActiveResource::Base.headers.delete('X-Shopify-Access-Token')
- end
+ def clear_session
+ self.site = nil
+ self.headers.delete('X-Shopify-Access-Token')
+ end
+ end
private
def only_id

0 comments on commit f6b03f2

Please sign in to comment.