Parcourir la source

Change Shop to a singlton class to clean up the current call.

Alex Aitken il y a 6 ans
Parent
commit
6322a6c270
1 fichiers modifiés avec 10 ajouts et 2 suppressions
  1. 10 2
      lib/shopify_api/resources/shop.rb

+ 10 - 2
lib/shopify_api/resources/shop.rb

@@ -2,8 +2,16 @@ module ShopifyAPI
   # Shop object. Use Shop.current to receive
   # the shop.
   class Shop < Base
-    def self.current(options={})
-      find(:one, options.merge({from: "/admin/shop.#{format.extension}"}))
+    if ActiveResource::VERSION::MAJOR >= 4
+      include ActiveResource::Singleton
+
+      def self.current(options={})
+        find(options)
+      end
+    else
+      def self.current(options={})
+        find(:one, options.merge({from: "/admin/shop.#{format.extension}"}))
+      end
     end
 
     def metafields(**options)