Class: UltraSettings::UninitializedRuntimeSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/ultra_settings/uninitialized_runtime_settings.rb

Overview

This class is used to represent runtime settings that have not been initialized yet. You can use this to protect your application from accidentally accessing runtime settings before they are initialized. Doing this can cause unexpected behavior if the runtime settings engine has not yet been initialized. For instance, if your runtime settings engine reads from a database it would not be available until the database connection is established.

The intention of this class is to set it as the runtime settings at the beginning of initialization and then set the actual runtime settings engine after the initialization is complete. It will act as a guard to prevent invalid runtime settings backed configurations from being used during initialization.

Examples:


UltraSettings.runtime_settings = UltraSettings::UninitializedRuntimeSettings
ActiveSupport.on_load(:active_record) do
  UltraSettings.runtime_settings = SuperSettings
end

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Class Method Details

.[](key) ⇒ void

This method returns an undefined value.

Raises an error when attempting to access runtime settings during initialization.

Parameters:

  • key (String)

    The key being accessed.

Raises:

  • (Error)

    Always raises an error to prevent access during initialization.



31
32
33
# File 'lib/ultra_settings/uninitialized_runtime_settings.rb', line 31

def [](key)
  raise Error.new("Attempt to call runtime setting #{key} during initialization")
end