Jelajahi Sumber

Ensure that we can serialize app charge resources

This is necessary because the charge resources have an attribute called
'test'. In ActiveModel's serializer it does a __send__ call to each
attribute to get it's value. Since Kernel provides a private #test method
that one will be favoured over our 'test' attribute and serialization will
raise an error.

This deletes Kernel#test when the class is defined so there's never a
conflict.
Jesse Storimer 14 tahun lalu
induk
melakukan
72e5591e53
1 mengubah file dengan 5 tambahan dan 1 penghapusan
  1. 5 1
      lib/shopify_api.rb

+ 5 - 1
lib/shopify_api.rb

@@ -469,6 +469,8 @@ module ShopifyAPI
   end
   
   class RecurringApplicationCharge < Base
+    undef_method :test
+
     def self.current
       find(:all).find{|charge| charge.status == 'active'}
     end
@@ -483,6 +485,8 @@ module ShopifyAPI
   end
 
   class ApplicationCharge < Base
+    undef_method :test
+
     def activate
       load_attributes_from_response(post(:activate))
     end
@@ -497,4 +501,4 @@ module ShopifyAPI
   EVENT_ENABLED_CLASSES.each do |klass|
     "ShopifyAPI::#{klass}".constantize.send(:include, Events)
   end
-end
+end