Module: Rimless::Extensions::ConfigurationHandling
- Extended by:
- ActiveSupport::Concern
- Included in:
- Rimless
- Defined in:
- lib/rimless/extensions/configuration_handling.rb
Overview
The top-level configuration handling.
rubocop:disable-next Style/ClassVars -- because we split module code
Class Method Summary collapse
-
.configuration ⇒ Configuration
Retrieve the current configuration object.
-
.configure {|configuration| ... } ⇒ Object
Configure the concern by providing a block which takes care of this task.
-
.env ⇒ ActiveSupport::StringInquirer
Retrieve the current configured environment.
-
.local_app_name ⇒ String?
Pass back the local application name.
-
.logger ⇒ Logger
Retrieve the current configured logger instance.
-
.reset_configuration! ⇒ Object
Reset the current configuration with the default one.
-
.topic_prefix(app = Rimless.configuration.app_name) ⇒ String
A simple convention helper to setup Apache Kafka topic names.
Class Method Details
.configuration ⇒ Configuration
Retrieve the current configuration object.
15 16 17 |
# File 'lib/rimless/extensions/configuration_handling.rb', line 15 def configuration @@configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Configure the concern by providing a block which takes care of this task. Example:
FactoryBot::Instrumentation.configure do |conf|
# conf.xyz = [..]
end
25 26 27 28 |
# File 'lib/rimless/extensions/configuration_handling.rb', line 25 def configure yield(configuration) configure_dependencies end |
.env ⇒ ActiveSupport::StringInquirer
Retrieve the current configured environment. You can use it like
Rails.env to query it. E.g. Rimless.env.production?.
39 40 41 42 43 |
# File 'lib/rimless/extensions/configuration_handling.rb', line 39 def env @@env = ActiveSupport::StringInquirer.new(configuration.env.to_s) \ if @env.to_s != configuration.env.to_s @@env end |
.local_app_name ⇒ String?
Pass back the local application name. When we are loaded together
with a Rails application we use the application class name. This
application name is URI/GID compatible. When no local application is
available, we just pass back nil.
59 60 61 62 63 64 65 66 67 |
# File 'lib/rimless/extensions/configuration_handling.rb', line 59 def local_app_name # Check for non-Rails integration return unless defined? Rails # Check if a application is defined return if Rails.application.nil? # Pass back the URI compatible application name Rails.application.class.module_parent_name.underscore.dasherize end |
.logger ⇒ Logger
Retrieve the current configured logger instance.
72 |
# File 'lib/rimless/extensions/configuration_handling.rb', line 72 delegate :logger, to: :configuration |
.reset_configuration! ⇒ Object
Reset the current configuration with the default one.
31 32 33 |
# File 'lib/rimless/extensions/configuration_handling.rb', line 31 def reset_configuration! @@configuration = Configuration.new end |
.topic_prefix(app = Rimless.configuration.app_name) ⇒ String
A simple convention helper to setup Apache Kafka topic names.
49 50 51 |
# File 'lib/rimless/extensions/configuration_handling.rb', line 49 def topic_prefix(app = Rimless.configuration.app_name) "#{Rimless.env}.#{app}." end |