Class: Aruba::ConfigWrapper
- Inherits:
-
Object
- Object
- Aruba::ConfigWrapper
- Defined in:
- lib/aruba/config_wrapper.rb
Overview
This wraps the current runtime configuration of aruba. If an option is changed, it notifies the event queue.
This class is not meant for direct use - ConfigWrapper.new - by normal users.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare two configs.
-
#initialize(config, event_bus) ⇒ ConfigWrapper
constructor
Create proxy.
-
#method_missing(name, *args, &block) ⇒ Object
Proxy all methods.
-
#respond_to?(m) ⇒ Boolean
Pass on respond_to?-calls.
-
#respond_to_missing?(name, _include_private) ⇒ Boolean
Pass on respond_to?-calls.
Constructor Details
#initialize(config, event_bus) ⇒ ConfigWrapper
Create proxy
23 24 25 26 |
# File 'lib/aruba/config_wrapper.rb', line 23 def initialize(config, event_bus) @config = config @event_bus = event_bus end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Proxy all methods
If one method ends with "=", e.g. ":option1=", then notify the event queue, that the user changes the value of "option1"
32 33 34 35 36 |
# File 'lib/aruba/config_wrapper.rb', line 32 def method_missing(name, *args, &block) event_bus.notify Events::ChangedConfiguration.new(:changed => { :name => name.to_s.gsub(/=$/, ''), :value => args.first }) if name.to_s.end_with? '=' config.send(name, *args, &block) end |
Instance Method Details
#==(other) ⇒ Object
Compare two configs
The comparism is done based on their values. No hooks are compared.
Somehow #respond_to_missing?
, method_missing?
and respond_to?
don't
help here.
49 50 51 |
# File 'lib/aruba/config_wrapper.rb', line 49 def ==(other) config == other end |
#respond_to?(m) ⇒ Boolean
Pass on respond_to?-calls
54 55 56 |
# File 'lib/aruba/config_wrapper.rb', line 54 def respond_to?(m) config.respond_to? m end |
#respond_to_missing?(name, _include_private) ⇒ Boolean
Pass on respond_to?-calls
39 40 41 |
# File 'lib/aruba/config_wrapper.rb', line 39 def respond_to_missing?(name, _include_private) config.respond_to? name end |