Class: ShopifyApp::ScripttagsManager
- Inherits:
-
Object
- Object
- ShopifyApp::ScripttagsManager
- Defined in:
- lib/shopify_app/scripttags_manager.rb
Defined Under Namespace
Classes: CreationFailed
Class Method Summary collapse
Instance Method Summary collapse
- #create_scripttags ⇒ Object
- #destroy_scripttags ⇒ Object
-
#initialize(shop_name, token) ⇒ ScripttagsManager
constructor
A new instance of ScripttagsManager.
- #recreate_scripttags! ⇒ Object
Constructor Details
#initialize(shop_name, token) ⇒ ScripttagsManager
Returns a new instance of ScripttagsManager.
9 10 11 |
# File 'lib/shopify_app/scripttags_manager.rb', line 9 def initialize(shop_name, token) @shop_name, @token = shop_name, token end |
Class Method Details
.queue(shop_name, token) ⇒ Object
5 6 7 |
# File 'lib/shopify_app/scripttags_manager.rb', line 5 def self.queue(shop_name, token) ShopifyApp::ScripttagsManagerJob.perform_later(shop_name: shop_name, token: token) end |
Instance Method Details
#create_scripttags ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/shopify_app/scripttags_manager.rb', line 18 def return unless .present? with_shopify_session do .each do |scripttag| create_scripttag(scripttag) unless scripttag_exists?(scripttag[:src]) end end end |
#destroy_scripttags ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/shopify_app/scripttags_manager.rb', line 28 def with_shopify_session do ShopifyAPI::ScriptTag.all.each do |scripttag| ShopifyAPI::ScriptTag.delete(scripttag.id) if is_required_scripttag?(scripttag) end end @current_scripttags = nil end |
#recreate_scripttags! ⇒ Object
13 14 15 16 |
# File 'lib/shopify_app/scripttags_manager.rb', line 13 def end |