Module: RailsOnboarding::Configuration::Steps

Included in:
RailsOnboarding::Configuration
Defined in:
lib/rails_onboarding/configuration/steps.rb

Overview

Onboarding step configuration and lookups.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#onboarding_required_forObject

Returns the value of attribute onboarding_required_for.



5
6
7
# File 'lib/rails_onboarding/configuration/steps.rb', line 5

def onboarding_required_for
  @onboarding_required_for
end

Instance Method Details

#step_by_name(name) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/rails_onboarding/configuration/steps.rb', line 30

def step_by_name(name)
  return nil if name.nil?

  @step_by_name_cache ||= {}
  @step_by_name_cache[name.to_sym] ||= steps.find do |s|
    next false unless s.is_a?(Hash) && s[:name]
    s[:name].to_sym == name.to_sym
  end
end

#step_index(name) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/rails_onboarding/configuration/steps.rb', line 40

def step_index(name)
  return nil if name.nil?

  @step_index_cache ||= {}
  @step_index_cache[name.to_sym] ||= steps.find_index do |s|
    next false unless s.is_a?(Hash) && s[:name]
    s[:name].to_sym == name.to_sym
  end
end

#stepsObject

Reads the active RailsOnboarding::Flow from the admin Flow Editor when one exists, falling back to the statically-configured steps otherwise. This keeps "activate a flow" a real, shared, durable change instead of a per-process global mutation - every process re-checks the database instead of caching a value that could go stale the moment another process (or another admin) activates a different flow.



13
14
15
16
17
18
# File 'lib/rails_onboarding/configuration/steps.rb', line 13

def steps
  flow_steps = active_flow_steps
  return hydrate_code_options(flow_steps) if flow_steps

  tenant_override(:steps, @steps)
end

#steps=(value) ⇒ Object

Override setter to clear cache when configuration changes



21
22
23
24
# File 'lib/rails_onboarding/configuration/steps.rb', line 21

def steps=(value)
  clear_cache!
  @steps = value
end

#total_stepsObject



26
27
28
# File 'lib/rails_onboarding/configuration/steps.rb', line 26

def total_steps
  @total_steps ||= steps.size
end