Class: QQQ::Developer

Inherits:
Object
  • Object
show all
Defined in:
lib/qqq.rb

Overview

Developer log channels

Instance Method Summary collapse

Constructor Details

#initializeDeveloper

Returns a new instance of Developer.



38
39
40
# File 'lib/qqq.rb', line 38

def initialize
  @mark_counter = 0
end

Instance Method Details

#markObject



42
43
44
45
# File 'lib/qqq.rb', line 42

def mark
  @mark_counter += 1
  publish("MARK: --MARK-- (#{@mark_counter})")
end

#publish(message) ⇒ Object



47
48
49
50
# File 'lib/qqq.rb', line 47

def publish(message)
  event = Event.from_message(message)
  redis.publish(Keys::EVENT_CHANNEL_KEY, event.to_json)
end

#subscribe(&block) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/qqq.rb', line 52

def subscribe &block
  redis.subscribe Keys::EVENT_CHANNEL_KEY do |on|
    on.message do |channel, event_json_string|
      event = Event.from_json_string(event_json_string)
      block.call(event)
    end
  end
end