Module: DemoMode

Defined in:
lib/demo_mode.rb,
lib/demo_mode/config.rb,
lib/demo_mode/engine.rb,
lib/demo_mode/persona.rb,
lib/demo_mode/version.rb,
app/models/demo_mode/session.rb,
app/jobs/demo_mode/account_generation_job.rb,
lib/generators/demo_mode/install_generator.rb,
app/controllers/concerns/demo_mode/demoable.rb,
app/controllers/demo_mode/sessions_controller.rb,
app/controllers/demo_mode/application_controller.rb

Defined Under Namespace

Modules: Clis, Demoable Classes: AccountGenerationJob, ApplicationController, Cli, Config, Engine, InstallGenerator, Persona, Session, SessionsController

Constant Summary collapse

VERSION =
'1.4.0'

Class Method Summary collapse

Class Method Details

.add_persona(name = default_name, &block) ⇒ Object



29
30
31
# File 'lib/demo_mode.rb', line 29

def add_persona(name = default_name, &block)
  configuration.persona(name, &block)
end

.callout_personasObject



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

def callout_personas
  personas.select(&:callout?)
end

.configure(&block) ⇒ Object



25
26
27
# File 'lib/demo_mode.rb', line 25

def configure(&block)
  configuration.instance_eval(&block)
end

.current_passwordObject



41
42
43
# File 'lib/demo_mode.rb', line 41

def current_password
  Thread.current[:_demo_mode_password] ||= password.call
end

.current_password=(value) ⇒ Object



45
46
47
# File 'lib/demo_mode.rb', line 45

def current_password=(value)
  Thread.current[:_demo_mode_password] = value
end

.enabled?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/demo_mode.rb', line 15

def enabled?
  ActiveModel::Type::Boolean::FALSE_VALUES.exclude?(ENV.fetch('DEMO_MODE', false)).tap do |enabled|
    webvalve_check! if enabled && defined?(WebValve)
  end
end

.session_url(session) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/demo_mode.rb', line 49

def session_url(session)
  routes = DemoMode::Engine.routes

  options = routes.default_url_options.presence
  options ||= ActionMailer::Base.default_url_options.presence if defined?(ActionMailer::Base)
  options ||= { only_path: true }

  routes.url_for(controller: 'demo_mode/sessions', action: 'show', id: session, **options)
end

.standard_personasObject



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

def standard_personas
  personas - callout_personas
end

.table_name_prefixObject



21
22
23
# File 'lib/demo_mode.rb', line 21

def table_name_prefix
  'demo_mode_'
end