Class: Rimless::Configuration
- Inherits:
-
ActiveSupport::OrderedOptions
- Object
- ActiveSupport::OrderedOptions
- Rimless::Configuration
- Defined in:
- lib/rimless/configuration.rb
Overview
The configuration for the rimless gem.
Class Method Summary collapse
-
.config_accessor(name, default = nil, &block) ⇒ Object
A simple DSL method to define new configuration accessors/settings with their defaults.
Instance Method Summary collapse
-
#consumer_job_queue=(val) ⇒ Object
A custom writer for the consumer job queue name.
-
#initialize(**args) ⇒ Configuration
constructor
Create a new
Configurationinstance with all settings populated with their respective defaults.
Constructor Details
#initialize(**args) ⇒ Configuration
Create a new Configuration instance with all settings populated with their respective defaults.
20 21 22 23 24 |
# File 'lib/rimless/configuration.rb', line 20 def initialize(**args) super() defaults.each { |key, default| self[key] = instance_exec(&default) } merge!(**args) end |
Class Method Details
.config_accessor(name, default = nil, &block) ⇒ Object
A simple DSL method to define new configuration accessors/settings with their defaults. The defaults can be retrieved with Configuration.defaults or Configuration.new.defaults.
36 37 38 39 40 41 42 43 44 |
# File 'lib/rimless/configuration.rb', line 36 def self.config_accessor(name, default = nil, &block) # Save the given configuration accessor default value defaults[name.to_sym] = block || -> { default } # Compile reader/writer methods so we don't have to go through # +ActiveSupport::OrderedOptions#method_missing+. define_method(name) { self[name] } define_method("#{name}=") { |value| self[name] = value } end |
Instance Method Details
#consumer_job_queue=(val) ⇒ Object
A custom writer for the consumer job queue name.
107 108 109 110 111 112 113 |
# File 'lib/rimless/configuration.rb', line 107 def consumer_job_queue=(val) self[:consumer_job_queue] = val.to_sym # Refresh the consumer job queue Rimless::ConsumerJob.( queue: Rimless.configuration.consumer_job_queue ) end |