Sha256: 3a6c4484ccd377f9c7b8d7f1ed76d572566f6e6f066399e5bda21924e187b029

Contents?: true

Size: 1.45 KB

Versions: 19

Compression:

Stored size: 1.45 KB

Contents

module Aruba
  # 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.
  #
  # @private
  class ConfigWrapper
    private

    attr_reader :config, :event_bus

    public

    # Create proxy
    #
    # @param [Config] config
    #   An aruba config object.
    #
    # @param [#notify] event_bus
    #   The event queue which should be notified.
    def initialize(config, event_bus)
      @config = config
      @event_bus = event_bus
    end

    # Proxy all methods
    #
    # If one method ends with "=", e.g. ":option1=", then notify the event
    # queue, that the user changes the value of "option1"
    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

    # Pass on respond_to?-calls
    def respond_to_missing?(name, _include_private)
      config.respond_to? name
    end

    # 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.
    def ==(other)
      config == other
    end

    # Pass on respond_to?-calls
    def respond_to?(m)
      config.respond_to? m
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
aruba-0.14.14 lib/aruba/config_wrapper.rb
aruba-0.14.13 lib/aruba/config_wrapper.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/aruba-0.14.12/lib/aruba/config_wrapper.rb
aruba-0.14.12 lib/aruba/config_wrapper.rb
aruba-0.14.11 lib/aruba/config_wrapper.rb
aruba-0.14.10 lib/aruba/config_wrapper.rb
aruba-0.14.9 lib/aruba/config_wrapper.rb
aruba-0.14.8 lib/aruba/config_wrapper.rb
aruba-0.14.7 lib/aruba/config_wrapper.rb
aruba-0.14.6 lib/aruba/config_wrapper.rb
aruba-0.14.5 lib/aruba/config_wrapper.rb
aruba-0.14.4 lib/aruba/config_wrapper.rb
aruba-0.14.3 lib/aruba/config_wrapper.rb
aruba-1.0.0.pre.alpha.2 lib/aruba/config_wrapper.rb
aruba-1.0.0.pre.alpha.1 lib/aruba/config_wrapper.rb
aruba-win-fix-0.14.2 lib/aruba/config_wrapper.rb
aruba-0.14.2 lib/aruba/config_wrapper.rb
aruba-0.14.1 lib/aruba/config_wrapper.rb
aruba-0.14.0 lib/aruba/config_wrapper.rb