Module: StateInspector::Reporter

Defined in:
lib/state_inspector/reporter.rb

Overview

OBSERVABLE PATTERN HASH-LIKE KEY OF OJECT TO OBSERVER/LOGGER INSTANCE

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



8
9
10
# File 'lib/state_inspector/reporter.rb', line 8

def [](key)
  reporters[key]
end

.[]=(key, value) ⇒ Object



12
13
14
# File 'lib/state_inspector/reporter.rb', line 12

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

.default(observer = nil) ⇒ Object



37
38
39
40
41
# File 'lib/state_inspector/reporter.rb', line 37

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

.drop(key) ⇒ Object



33
34
35
# File 'lib/state_inspector/reporter.rb', line 33

def drop key
  reporters.delete key
end

.get(key) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/state_inspector/reporter.rb', line 24

def get key
  unless key.respond_to?(:class_exec)
    unless reporters.has_key?(key)
      return self[key.class] 
    end
  end
  self[key] 
end

.has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/state_inspector/reporter.rb', line 16

def has_key? key
  reporters.has_key?(key)
end

.has_observer?(key) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/state_inspector/reporter.rb', line 20

def has_observer? key
  reporters.has_key?(key) || (reporters.has_key?(key.class) if key.respond_to?(:class_exec))
end