Module: Rimless::ConfigurationHandling
- Extended by:
- ActiveSupport::Concern
- Included in:
- Rimless
- Defined in:
- lib/rimless/configuration_handling.rb
Overview
The top-level configuration handling.
rubocop:disable 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.
14 15 16 |
# File 'lib/rimless/configuration_handling.rb', line 14 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
24 25 26 27 |
# File 'lib/rimless/configuration_handling.rb', line 24 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?
.
38 39 40 41 42 |
# File 'lib/rimless/configuration_handling.rb', line 38 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
.
58 59 60 61 62 63 64 65 66 |
# File 'lib/rimless/configuration_handling.rb', line 58 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.parent_name.underscore.dasherize end |
.logger ⇒ Logger
Retrieve the current configured logger instance.
71 |
# File 'lib/rimless/configuration_handling.rb', line 71 delegate :logger, to: :configuration |
.reset_configuration! ⇒ Object
Reset the current configuration with the default one.
30 31 32 |
# File 'lib/rimless/configuration_handling.rb', line 30 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.
48 49 50 |
# File 'lib/rimless/configuration_handling.rb', line 48 def topic_prefix(app = Rimless.configuration.app_name) "#{Rimless.env}.#{app}." end |