ソースを参照

Move disable prefix check into the shopify_api namespace.

This module assumes access to methods that are defined by the
ShopifyAPI::Base class and is not a generic ActiveResource extension.
Alex Aitken 6 年 前
コミット
11886ae54c
1 ファイル変更19 行追加17 行削除
  1. 19 17
      lib/active_resource/disable_prefix_check.rb

+ 19 - 17
lib/active_resource/disable_prefix_check.rb

@@ -1,26 +1,28 @@
-module DisablePrefixCheck
-  extend ActiveSupport::Concern
+module ShopifyAPI
+  module DisablePrefixCheck
+    extend ActiveSupport::Concern
 
-  module ClassMethods
-    def check_prefix_options(options)
-    end
+    module ClassMethods
+      def check_prefix_options(options)
+      end
 
-    # `flexible = true` is hack to allow multiple things through the same AR class
-    def conditional_prefix(resource, flexible = false)
-      resource_id = "#{resource}_id".to_sym
-      resource_type = flexible ? ":#{resource}" : resource.to_s.pluralize
+      # `flexible = true` is hack to allow multiple things through the same AR class
+      def conditional_prefix(resource, flexible = false)
+        resource_id = "#{resource}_id".to_sym
+        resource_type = flexible ? ":#{resource}" : resource.to_s.pluralize
 
-      init_prefix_explicit resource_type, resource_id
+        init_prefix_explicit resource_type, resource_id
 
-      define_singleton_method :prefix do |options = {}|
-        resource_type =  options[resource] if flexible
+        define_singleton_method :prefix do |options = {}|
+          resource_type =  options[resource] if flexible
 
-        options[resource_id].nil? ? "/admin/" : "/admin/#{resource_type}/#{options[resource_id]}/"
-      end
+          options[resource_id].nil? ? "/admin/" : "/admin/#{resource_type}/#{options[resource_id]}/"
+        end
 
-      define_singleton_method :instantiate_record do |record, prefix_options = {}|
-        new(record, true).tap do |resource_instance|
-          resource_instance.prefix_options = prefix_options unless prefix_options.blank?
+        define_singleton_method :instantiate_record do |record, prefix_options = {}|
+          new(record, true).tap do |resource_instance|
+            resource_instance.prefix_options = prefix_options unless prefix_options.blank?
+          end
         end
       end
     end