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.
Defined Under Namespace
Classes: Future
Class Attribute Summary collapse
-
.autoload_static_config_path ⇒ Object
Returns the value of attribute autoload_static_config_path.
- .autoload_via_zeitwerk ⇒ Object
-
.autoloader ⇒ Object
readonly
Returns the value of attribute autoloader.
-
.current_environment ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc).
-
.default_config_path ⇒ Object
A proc returning a path to YML config file given the config name.
-
.default_environmental_key ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc).
-
.known_environments ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc).
-
.tracing_enabled ⇒ Object
Enable source tracing.
-
.use_local_files ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc).
Class Method Summary collapse
- .app_root ⇒ Object
- .cleanup_autoload_paths ⇒ Object
- .default_environmental_key? ⇒ Boolean
- .future ⇒ Object
- .matching_env?(env) ⇒ Boolean
Class Attribute Details
.autoload_static_config_path ⇒ Object
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 |
.autoload_via_zeitwerk ⇒ Object
62 63 64 65 66 |
# File 'lib/anyway/rails/settings.rb', line 62 def autoload_via_zeitwerk return @autoload_via_zeitwerk if instance_variable_defined?(:@autoload_via_zeitwerk) @autoload_via_zeitwerk = defined?(::Zeitwerk) end |
.autoloader ⇒ Object (readonly)
Returns the value of attribute autoloader.
13 14 15 |
# File 'lib/anyway/rails/settings.rb', line 13 def autoloader @autoloader end |
.current_environment ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc)
50 51 52 |
# File 'lib/anyway/settings.rb', line 50 def current_environment @current_environment end |
.default_config_path ⇒ Object
A proc returning a path to YML config file given the config name
56 57 58 |
# File 'lib/anyway/settings.rb', line 56 def default_config_path @default_config_path end |
.default_environmental_key ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc)
50 51 52 |
# File 'lib/anyway/settings.rb', line 50 def default_environmental_key @default_environmental_key end |
.known_environments ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc)
50 51 52 |
# File 'lib/anyway/settings.rb', line 50 def known_environments @known_environments end |
.tracing_enabled ⇒ Object
Enable source tracing
70 71 72 |
# File 'lib/anyway/settings.rb', line 70 def tracing_enabled @tracing_enabled end |
.use_local_files ⇒ Object
Define whether to load data from *.yml.local (or credentials/local.yml.enc)
50 51 52 |
# File 'lib/anyway/settings.rb', line 50 def use_local_files @use_local_files end |
Class Method Details
.app_root ⇒ Object
76 77 78 |
# File 'lib/anyway/settings.rb', line 76 def app_root Pathname.new(Dir.pwd) end |
.cleanup_autoload_paths ⇒ Object
55 56 57 58 59 60 |
# File 'lib/anyway/rails/settings.rb', line 55 def cleanup_autoload_paths return unless autoload_via_zeitwerk return unless autoload_static_config_path ActiveSupport::Dependencies.autoload_paths.delete(::Rails.root.join(autoload_static_config_path).to_s) end |
.default_environmental_key? ⇒ Boolean
80 81 82 |
# File 'lib/anyway/settings.rb', line 80 def default_environmental_key? !default_environmental_key.nil? end |
.future ⇒ Object
72 73 74 |
# File 'lib/anyway/settings.rb', line 72 def future @future ||= Future.new end |
.matching_env?(env) ⇒ Boolean
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/anyway/settings.rb', line 84 def matching_env?(env) return true if env.nil? || env.to_s == current_environment if env.is_a?(::Hash) envs = env[:except] excluded_envs = [envs].flat_map(&:to_s) excluded_envs.none?(current_environment) elsif env.is_a?(::Array) env.flat_map(&:to_s).include?(current_environment) else false end end |