Просмотр исходного кода

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

Alex Aitken 6 лет назад
Родитель
Сommit
6322a6c270
1 измененных файлов с 10 добавлено и 2 удалено
  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)