Permalink
Browse files

Backport ActiveResource patch to inherit headers from parent classes.

See rails commit c5bf53822f5887c9b235ceef388b1c8a977bcc88.
  • Loading branch information...
1 parent b11300a commit e5bfac552260f8314b04784180a6c2693a491eea @dylanahsmith dylanahsmith committed Mar 13, 2012
Showing with 15 additions and 5 deletions.
  1. +14 −0 lib/active_resource/base_ext.rb
  2. +1 −0 lib/shopify_api.rb
  3. +0 −5 lib/shopify_api/resources/base.rb
@@ -0,0 +1,14 @@
+module ActiveResource
+ class Base
+ # Backported from ActiveResource master branch
+ def self.headers
+ @headers ||= {}
+
+ if superclass != Object && superclass.headers
+ @headers = superclass.headers.merge(@headers)
+ else
+ @headers
+ end
+ end
+ end
+end
View
@@ -10,6 +10,7 @@
require 'shopify_api/json_format'
require 'active_resource/json_errors'
require 'active_resource/disable_prefix_check'
+require 'active_resource/base_ext'
module ShopifyAPI
include Limits
@@ -4,11 +4,6 @@ module ShopifyAPI
class Base < ActiveResource::Base
extend Countable
self.include_root_in_json = false
-
- def self.inherited(klass)
- super
- klass.headers['User-Agent'] = Base.headers['User-Agent']
- end
self.headers['User-Agent'] = ["ShopifyAPI/#{ShopifyAPI::VERSION}",
"ActiveResource/#{ActiveResource::VERSION::STRING}",
"Ruby/#{RUBY_VERSION}"].join(' ')

0 comments on commit e5bfac5

Please sign in to comment.