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).
-
.suppress_required_validations ⇒ Object
Suppress required validations for CI/CD pipelines.
-
.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
59 60 61 |
# File 'lib/anyway/settings.rb', line 59 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 |
.suppress_required_validations ⇒ Object
Suppress required validations for CI/CD pipelines
56 57 58 |
# File 'lib/anyway/settings.rb', line 56 def suppress_required_validations @suppress_required_validations end |
.tracing_enabled ⇒ Object
Enable source tracing
73 74 75 |
# File 'lib/anyway/settings.rb', line 73 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
79 80 81 |
# File 'lib/anyway/settings.rb', line 79 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
83 84 85 |
# File 'lib/anyway/settings.rb', line 83 def default_environmental_key? !default_environmental_key.nil? end |
.future ⇒ Object
75 76 77 |
# File 'lib/anyway/settings.rb', line 75 def future @future ||= Future.new end |
.matching_env?(env) ⇒ Boolean
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/anyway/settings.rb', line 87 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 |