Module: Consently

Defined in:
lib/consently.rb,
lib/consently/cookie.rb,
lib/consently/engine.rb,
lib/consently/script.rb,
lib/consently/consent.rb,
lib/consently/version.rb,
lib/consently/configuration.rb,
lib/consently/providers/base.rb,
lib/consently/providers/custom.rb,
lib/consently/providers/hotjar.rb,
lib/consently/providers/clarity.rb,
app/helpers/consently/tags_helper.rb,
lib/consently/providers/plausible.rb,
lib/consently/providers/google_ads.rb,
lib/consently/providers/meta_pixel.rb,
app/models/consently/consent_record.rb,
app/models/consently/application_record.rb,
app/helpers/consently/application_helper.rb,
lib/consently/providers/google_analytics.rb,
lib/consently/providers/google_tag_manager.rb,
app/controllers/consently/consents_controller.rb,
lib/generators/consently/views/views_generator.rb,
app/controllers/consently/application_controller.rb,
lib/generators/consently/install/install_generator.rb,
lib/generators/consently/consent_log/consent_log_generator.rb

Overview

Tag snippets and cookie consent in one place.

Everything the host application needs goes through Consently.configure; the views ask this module what to render for the current request.

Defined Under Namespace

Modules: ApplicationHelper, Generators, Providers, TagsHelper Classes: ApplicationController, ApplicationRecord, Configuration, Consent, ConsentRecord, ConsentsController, Cookie, Engine, Error, MissingOption, Script, UnknownProvider

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.configObject



37
38
39
# File 'lib/consently.rb', line 37

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



32
33
34
35
# File 'lib/consently.rb', line 32

def configure
  yield config
  config
end

Whether this visitor has to be asked. When they do not, every category counts as granted and no banner is rendered - see config.consent_required.

Returns:

  • (Boolean)


64
65
66
# File 'lib/consently.rb', line 64

def consent_required?(request = nil)
  resolve(config.consent_required, request)
end

.enabled?(request = nil) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/consently.rb', line 58

def enabled?(request = nil)
  resolve(config.enabled, request)
end

.reset!Object

Mostly for tests and for reloading an initializer in development.



42
43
44
# File 'lib/consently.rb', line 42

def reset!
  @config = Configuration.new
end

.scope_for(request) ⇒ Object



52
53
54
55
56
# File 'lib/consently.rb', line 52

def scope_for(request)
  return nil unless config.scope_resolver && request

  config.scope_resolver.call(request)
end

.tags_for(request = nil) ⇒ Object

Tags configured for this request: the defaults, plus whatever the matching scope adds or overrides.



48
49
50
# File 'lib/consently.rb', line 48

def tags_for(request = nil)
  config.tags_for(scope_for(request))
end