Sha256: c7bbfb49e04f9debb0d33dda1c43d367ac7b81d4dd9ed62570d7f4357ce283d7

Contents?: true

Size: 608 Bytes

Versions: 7

Compression:

Stored size: 608 Bytes

Contents

require_relative 'observers/null_observer'

module StateInspector
  # OBSERVABLE PATTERN
  # HASH-LIKE KEY OF OJECT TO OBSERVER/LOGGER INSTANCE
  module Reporter
    class << self
      def [](key)
        reporters[key]
      end

      def []=(key, value)
        reporters[key] = value
      end

      def default observer=nil
        @default = observer if observer
        reporters.default = @default 
        @default
      end

      private
      def reporters
        @reporters ||= Hash.new.tap {|h|
          h.default = @default || Observers::NullObserver
        }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
state_inspector-1.0.2 lib/state_inspector/reporter.rb
state_inspector-1.0.1 lib/state_inspector/reporter.rb
state_inspector-1.0.0 lib/state_inspector/reporter.rb
state_inspector-1.0.0.rc1 lib/state_inspector/reporter.rb
state_inspector-0.8.2 lib/state_inspector/reporter.rb
state_inspector-0.8.1 lib/state_inspector/reporter.rb
state_inspector-0.8.0 lib/state_inspector/reporter.rb