Class: Shugoi::GuardInjector
- Inherits:
-
Object
- Object
- Shugoi::GuardInjector
- Defined in:
- lib/shugoi/guard_injector.rb
Instance Method Summary collapse
- #call(html) ⇒ Object
-
#initialize(config, token_signer, html_store, skeleton) ⇒ GuardInjector
constructor
A new instance of GuardInjector.
Constructor Details
#initialize(config, token_signer, html_store, skeleton) ⇒ GuardInjector
Returns a new instance of GuardInjector.
3 4 5 6 7 8 |
# File 'lib/shugoi/guard_injector.rb', line 3 def initialize(config, token_signer, html_store, skeleton) @config = config @token_signer = token_signer @html_store = html_store @skeleton = skeleton end |
Instance Method Details
#call(html) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/shugoi/guard_injector.rb', line 10 def call(html) signed = @token_signer.sign(@config.site_key, Utils.now_ms) config_script = @config.restricted_access ? "" : "<script>window.__sg_disableRestrictedAccess=true</script>" injected = insert_config(html, config_script) @html_store.store(signed, injected, @config.site_key) @skeleton.generate(@config.site_key, signed, @config.base_url, "./__shugoi/render") end |