Module: ActiveShopifyGraphQL::Model::LoaderSwitchable
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActiveShopifyGraphQL::Model
- Defined in:
- lib/active_shopify_graphql/model/loader_switchable.rb
Instance Method Summary collapse
-
#with_admin_api(&block) ⇒ self
Executes with the admin API loader.
-
#with_customer_account_api(&block) ⇒ self
Executes with the customer account API loader.
-
#with_loader(loader_class) {|Object| ... } ⇒ Object
Generic method to execute with a specific loader.
Instance Method Details
#with_admin_api(&block) ⇒ self
Executes with the admin API loader
26 27 28 |
# File 'lib/active_shopify_graphql/model/loader_switchable.rb', line 26 def with_admin_api(&block) with_loader(ActiveShopifyGraphQL::Loaders::AdminApiLoader, &block) end |
#with_customer_account_api(&block) ⇒ self
Executes with the customer account API loader
32 33 34 |
# File 'lib/active_shopify_graphql/model/loader_switchable.rb', line 32 def with_customer_account_api(&block) with_loader(ActiveShopifyGraphQL::Loaders::CustomerAccountApiLoader, &block) end |
#with_loader(loader_class) {|Object| ... } ⇒ Object
Generic method to execute with a specific loader
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/active_shopify_graphql/model/loader_switchable.rb', line 11 def with_loader(loader_class, &_block) old_loader = Thread.current[:active_shopify_graphql_loader] Thread.current[:active_shopify_graphql_loader] = loader_class.new(self.class) if block_given? yield(self) else self end ensure Thread.current[:active_shopify_graphql_loader] = old_loader end |