Sha256: 20d0df5849e7e0e9af0f32771bac2d0595aa8db4432e5bdeb19cd22a74a375d9
Contents?: true
Size: 904 Bytes
Versions: 1
Compression:
Stored size: 904 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 has_key? key reporters.has_key?(key) end def has_observer? key class_key = key.respond_to?(:class_eval) ? key : key.class reporters.has_key?(key) || reporters.has_key?(class_key) end def drop key reporters.delete key 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
state_inspector-1.0.3 | lib/state_inspector/reporter.rb |