Class: RailsOnboarding::Configuration

Inherits:
Object
  • Object
show all
Includes:
AbTesting, Analytics, Integrations, Milestones, Personalization, ProgressiveDisclosure, RateLimiting, Steps, Templates, Tooltips
Defined in:
lib/rails_onboarding/configuration.rb,
lib/rails_onboarding/configuration/steps.rb,
lib/rails_onboarding/configuration/tooltips.rb,
lib/rails_onboarding/configuration/analytics.rb,
lib/rails_onboarding/configuration/templates.rb,
lib/rails_onboarding/configuration/ab_testing.rb,
lib/rails_onboarding/configuration/milestones.rb,
lib/rails_onboarding/configuration/integrations.rb,
lib/rails_onboarding/configuration/rate_limiting.rb,
lib/rails_onboarding/configuration/personalization.rb,
lib/rails_onboarding/configuration/progressive_disclosure.rb

Overview

Every reader/writer here is part of this gem's public configuration DSL (host apps set these in a RailsOnboarding.configure block), so none of them can change shape without breaking every existing installation. The ~40 settings are grouped by feature into the modules under configuration/ - each one owns its own defaults and any logic specific to it, so a change to (say) A/B testing only touches configuration/ab_testing.rb instead of this whole file. What's left here is identity/branding settings with no logic of their own, plus the infrastructure the feature modules share (tenant overrides, the derived- lookup cache, and the validator).

Defined Under Namespace

Modules: AbTesting, Analytics, Integrations, Milestones, Personalization, ProgressiveDisclosure, RateLimiting, Steps, Templates, Tooltips

Instance Attribute Summary collapse

Attributes included from Templates

#onboarding_templates

Attributes included from RateLimiting

#rate_limit_per_period, #rate_limit_period, #rate_limiting_enabled

Attributes included from Integrations

#api_authentication_method, #api_mode_enabled, #background_jobs_enabled, #background_jobs_queue, #devise_integration_enabled, #mailer_from, #redirect_unconfirmed_to_onboarding, #turbo_morphing_enabled, #turbo_streams_enabled

Attributes included from ProgressiveDisclosure

#progressive_disclosure_enabled, #progressive_features

Attributes included from Personalization

#personalization_enabled, #personalized_flows, #user_type_method

Attributes included from AbTesting

#ab_tests, #enable_ab_testing

Attributes included from Analytics

#analytics_data_retention_days, #analytics_retention_days, #analytics_session_timeout_minutes, #enable_analytics

Attributes included from Tooltips

#enable_tooltips, #feature_tooltips

Attributes included from Milestones

#enable_milestones

Attributes included from Steps

#onboarding_required_for

Instance Method Summary collapse

Methods included from Templates

#apply_template, #template

Methods included from ProgressiveDisclosure

#show_progressive_feature?

Methods included from Personalization

#personalized_flow

Methods included from AbTesting

#ab_test

Methods included from Milestones

#milestone_by_key, #milestones, #milestones=, #milestones_for_trigger

Methods included from Steps

#step_by_name, #step_index, #steps, #steps=, #total_steps

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rails_onboarding/configuration.rb', line 47

def initialize
  @user_class_name = "User"
  @include_host_styles = true  # Default to including host app css
  @redirect_after_completion = :root_path
  @redirect_after_skip = :root_path
  @welcome_heading = "We're excited to have you here!"
  @welcome_subheading = "Now, let's take a few moments to get you set up and familiar with a few things you need to know to get started."
  @welcome_features = [
    { icon: "👤", text: "Set up your profile" },
    { icon: "📝", text: "Create your first item" },
    { icon: "🔍", text: "Explore key features" }
  ]

  # Optional override for the admin User Management search box. The
  # built-in search is plain SQL, which can't see through an encrypted
  # email column - a host app that encrypts email and still wants partial
  # matching has to supply the strategy itself. Receives the already
  # status/step-filtered scope and the raw term, and must return a
  # relation (not an array) so sorting and pagination still apply.
  @admin_user_search = nil

  initialize_steps
  initialize_milestones
  initialize_tooltips
  initialize_analytics
  initialize_ab_testing
  initialize_personalization
  initialize_progressive_disclosure
  initialize_integrations
  initialize_rate_limiting
  initialize_templates
end

Instance Attribute Details

#admin_user_searchObject

Returns the value of attribute admin_user_search.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def admin_user_search
  @admin_user_search
end

#custom_css_pathObject

Returns the value of attribute custom_css_path.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def custom_css_path
  @custom_css_path
end

#custom_js_pathObject

Returns the value of attribute custom_js_path.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def custom_js_path
  @custom_js_path
end

#include_host_stylesObject

Returns the value of attribute include_host_styles.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def include_host_styles
  @include_host_styles
end

#redirect_after_completionObject

Returns the value of attribute redirect_after_completion.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def redirect_after_completion
  @redirect_after_completion
end

#redirect_after_skipObject

Returns the value of attribute redirect_after_skip.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def redirect_after_skip
  @redirect_after_skip
end

#user_class_nameObject

Returns the value of attribute user_class_name.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def user_class_name
  @user_class_name
end

#welcome_featuresObject

Returns the value of attribute welcome_features.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def welcome_features
  @welcome_features
end

#welcome_headingObject

Returns the value of attribute welcome_heading.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def welcome_heading
  @welcome_heading
end

#welcome_subheadingObject

Returns the value of attribute welcome_subheading.



36
37
38
# File 'lib/rails_onboarding/configuration.rb', line 36

def welcome_subheading
  @welcome_subheading
end

Instance Method Details

#clear_cache!Object

Clear all cached lookups - call this when configuration changes



109
110
111
112
113
114
115
116
117
# File 'lib/rails_onboarding/configuration.rb', line 109

def clear_cache!
  @user_class = nil
  @total_steps = nil
  @step_by_name_cache = nil
  @step_index_cache = nil
  @milestone_by_key_cache = nil
  @milestones_for_trigger_cache = nil
  @validator = nil
end

#user_classObject



104
105
106
# File 'lib/rails_onboarding/configuration.rb', line 104

def user_class
  @user_class ||= @user_class_name.constantize
end

#valid?Boolean

Check if the configuration is valid without raising

Returns:

  • (Boolean)

    true if valid, false otherwise



88
89
90
# File 'lib/rails_onboarding/configuration.rb', line 88

def valid?
  validator.valid?
end

#validate!Object

Validate the current configuration

Raises:



82
83
84
# File 'lib/rails_onboarding/configuration.rb', line 82

def validate!
  validator.validate!
end

#validation_errorsArray<StandardError>

Get validation errors without raising

Returns:

  • (Array<StandardError>)

    array of validation errors



100
101
102
# File 'lib/rails_onboarding/configuration.rb', line 100

def validation_errors
  validator.errors
end

#validatorConfigurationValidator

Get the validator instance for this configuration



94
95
96
# File 'lib/rails_onboarding/configuration.rb', line 94

def validator
  @validator ||= ConfigurationValidator.new(self)
end