Class: DuodealerApp::ScripttagsManager
- Inherits:
-
Object
- Object
- DuodealerApp::ScripttagsManager
- Defined in:
- lib/duodealer_app/managers/scripttags_manager.rb
Defined Under Namespace
Classes: CreationFailed
Instance Attribute Summary collapse
-
#account_domain ⇒ Object
readonly
Returns the value of attribute account_domain.
-
#required_scripttags ⇒ Object
readonly
Returns the value of attribute required_scripttags.
Class Method Summary collapse
Instance Method Summary collapse
- #create_scripttags ⇒ Object
- #destroy_scripttags ⇒ Object
-
#initialize(scripttags, account_domain) ⇒ ScripttagsManager
constructor
A new instance of ScripttagsManager.
- #recreate_scripttags! ⇒ Object
Constructor Details
#initialize(scripttags, account_domain) ⇒ ScripttagsManager
Returns a new instance of ScripttagsManager.
27 28 29 30 |
# File 'lib/duodealer_app/managers/scripttags_manager.rb', line 27 def initialize(, account_domain) @required_scripttags = @account_domain = account_domain end |
Instance Attribute Details
#account_domain ⇒ Object (readonly)
Returns the value of attribute account_domain.
25 26 27 |
# File 'lib/duodealer_app/managers/scripttags_manager.rb', line 25 def account_domain @account_domain end |
#required_scripttags ⇒ Object (readonly)
Returns the value of attribute required_scripttags.
25 26 27 |
# File 'lib/duodealer_app/managers/scripttags_manager.rb', line 25 def @required_scripttags end |
Class Method Details
.build_src(scripttags, domain) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/duodealer_app/managers/scripttags_manager.rb', line 16 def self.build_src(, domain) .map do |tag| next tag unless tag[:src].respond_to?(:call) tag = tag.dup tag[:src] = tag[:src].call(domain) tag end end |
.queue(account_domain, account_token, scripttags) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/duodealer_app/managers/scripttags_manager.rb', line 7 def self.queue(account_domain, account_token, ) DuodealerApp::ScripttagsManagerJob.perform_later( account_domain: account_domain, account_token: account_token, # Procs cannot be serialized so we interpolate now, if necessary scripttags: build_src(, account_domain) ) end |
Instance Method Details
#create_scripttags ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/duodealer_app/managers/scripttags_manager.rb', line 37 def return if .blank? .each do |scripttag| create_scripttag(scripttag) unless scripttag_exists?(scripttag[:src]) end end |
#destroy_scripttags ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/duodealer_app/managers/scripttags_manager.rb', line 45 def = DuodealerAPI::ScriptTag.all.each do |tag| DuodealerAPI::ScriptTag.delete(tag.id) if is_required_scripttag?(, tag) end @current_scripttags = nil end |
#recreate_scripttags! ⇒ Object
32 33 34 35 |
# File 'lib/duodealer_app/managers/scripttags_manager.rb', line 32 def end |