Class: OmniKiq::Configuration
- Inherits:
-
Object
- Object
- OmniKiq::Configuration
- Includes:
- Module.new
- Defined in:
- lib/omnikiq/configuration.rb
Constant Summary collapse
- READERS =
Module that holds ‘attr_reader` declarations. It’s in a separate module to allow us to override those methods and use ‘super`.
Module.new
Class Method Summary collapse
-
.add_read_only_setting(name, _opts = {}) ⇒ Object
As ‘add_setting` but only add the reader.
-
.add_setting(name, opts = {}) ⇒ Object
Invoked by the ‘add_setting` instance method.
- .define_aliases(name, alias_name) ⇒ Object
- .define_predicate_for(*names) ⇒ Object
- .define_reader(name) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
52 53 54 55 56 57 |
# File 'lib/omnikiq/configuration.rb', line 52 def initialize @mixpanel_api_key = '' @redis_url = 'redis://localhost:6379' @redis_namespace = ENV['RACK_ENV'] || 'default' @test_mode = false end |
Class Method Details
.add_read_only_setting(name, _opts = {}) ⇒ Object
As ‘add_setting` but only add the reader.
42 43 44 45 |
# File 'lib/omnikiq/configuration.rb', line 42 def self.add_read_only_setting(name, _opts = {}) define_reader name define_predicate_for name end |
.add_setting(name, opts = {}) ⇒ Object
Invoked by the ‘add_setting` instance method. Use that method on a `Configuration` instance rather than this class method.
32 33 34 35 36 37 38 |
# File 'lib/omnikiq/configuration.rb', line 32 def self.add_setting(name, opts = {}) attr_writer name add_read_only_setting name Array(opts[:alias_with]).each do |alias_name| define_aliases(name, alias_name) end end |
.define_aliases(name, alias_name) ⇒ Object
18 19 20 21 22 |
# File 'lib/omnikiq/configuration.rb', line 18 def self.define_aliases(name, alias_name) alias_method alias_name, name alias_method "#{alias_name}=", "#{name}=" define_predicate_for alias_name end |
.define_predicate_for(*names) ⇒ Object
25 26 27 |
# File 'lib/omnikiq/configuration.rb', line 25 def self.define_predicate_for(*names) names.each { |name| alias_method "#{name}?", name } end |
.define_reader(name) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/omnikiq/configuration.rb', line 10 def self.define_reader(name) READERS.class_eval do remove_method name if method_defined?(name) attr_reader name end end |