Class: Anyway::Settings
- Inherits:
-
Object
- Object
- Anyway::Settings
- Defined in:
- lib/anyway/settings.rb,
lib/anyway/rails/settings.rb
Overview
Use Settings name to not confuse with Config.
Settings contain the library-wide configuration.
Class Attribute Summary collapse
-
.autoload_static_config_path ⇒ Object
readonly
Returns the value of attribute autoload_static_config_path.
-
.default_config_path ⇒ Object
Return a path to YML config file given the config name.
-
.tracing_enabled ⇒ Object
Enable source tracing.
-
.use_local_files ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc).
Instance Attribute Summary collapse
-
#autoloader ⇒ Object
readonly
Returns the value of attribute autoloader.
Instance Method Summary collapse
Class Attribute Details
.autoload_static_config_path ⇒ Object (readonly)
Returns the value of attribute autoload_static_config_path.
13 14 15 |
# File 'lib/anyway/rails/settings.rb', line 13 def autoload_static_config_path @autoload_static_config_path end |
.default_config_path ⇒ Object
Return a path to YML config file given the config name
14 15 16 |
# File 'lib/anyway/settings.rb', line 14 def default_config_path @default_config_path end |
.tracing_enabled ⇒ Object
Enable source tracing
17 18 19 |
# File 'lib/anyway/settings.rb', line 17 def tracing_enabled @tracing_enabled end |
.use_local_files ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc)
11 12 13 |
# File 'lib/anyway/settings.rb', line 11 def use_local_files @use_local_files end |
Instance Attribute Details
#autoloader ⇒ Object (readonly)
Returns the value of attribute autoloader.
16 17 18 |
# File 'lib/anyway/rails/settings.rb', line 16 def autoloader @autoloader end |
Instance Method Details
#autoload_static_config_path=(val) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/anyway/rails/settings.rb', line 18 def autoload_static_config_path=(val) raise "Cannot setup autoloader after application has been initialized" if ::Rails.application.initialized? return unless ::Rails.root.join(val).exist? autoloader&.unload @autoload_static_config_path = val # See https://github.com/rails/rails/blob/8ab4fd12f18203b83d0f252db96d10731485ff6a/railties/lib/rails/autoloaders.rb#L10 @autoloader = Zeitwerk::Loader.new.tap do |loader| loader.tag = "anyway.config" loader.inflector = ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector loader.push_dir(::Rails.root.join(val)) loader.setup end end |
#cleanup_autoload_paths ⇒ Object
36 37 38 39 |
# File 'lib/anyway/rails/settings.rb', line 36 def cleanup_autoload_paths return unless autoload_static_config_path ActiveSupport::Dependencies.autoload_paths.delete(::Rails.root.join(autoload_static_config_path).to_s) end |