Class: ShopifyApp::ScripttagsManager

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_app/scripttags_manager.rb

Defined Under Namespace

Classes: CreationFailed

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.queue(shop_domain, shop_token) ⇒ Object



5
6
7
# File 'lib/shopify_app/scripttags_manager.rb', line 5

def self.queue(shop_domain, shop_token)
  ShopifyApp::ScripttagsManagerJob.perform_later(shop_domain: shop_domain, shop_token: shop_token)
end

Instance Method Details

#create_scripttagsObject



14
15
16
17
18
19
20
# File 'lib/shopify_app/scripttags_manager.rb', line 14

def create_scripttags
  return unless required_scripttags.present?

  required_scripttags.each do |scripttag|
    create_scripttag(scripttag) unless scripttag_exists?(scripttag[:src])
  end
end

#destroy_scripttagsObject



22
23
24
25
26
27
28
# File 'lib/shopify_app/scripttags_manager.rb', line 22

def destroy_scripttags
  ShopifyAPI::ScriptTag.all.each do |scripttag|
    ShopifyAPI::ScriptTag.delete(scripttag.id) if is_required_scripttag?(scripttag)
  end

  @current_scripttags = nil
end

#recreate_scripttags!Object



9
10
11
12
# File 'lib/shopify_app/scripttags_manager.rb', line 9

def recreate_scripttags!
  destroy_scripttags
  create_scripttags
end