Sha256: bc172d969f3284a7be17ba9df1f28cc30df095ffdfb5da5c5a58369e1c112037
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_exec) ? 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.4 | lib/state_inspector/reporter.rb |