Module: Orchestra

Defined in:
lib/orchestra.rb,
lib/orchestra/event.rb,
lib/orchestra/version.rb,
lib/orchestra/publisher.rb,
lib/orchestra/subscriber.rb

Defined Under Namespace

Classes: Event, Publisher, Subscriber

Constant Summary collapse

VERSION =
"0.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.publisherObject

Returns the value of attribute publisher.



13
14
15
# File 'lib/orchestra.rb', line 13

def publisher
  @publisher
end

Class Method Details

.begin(name, *payload) ⇒ Object



15
16
17
18
19
20
# File 'lib/orchestra.rb', line 15

def begin(name, *payload)
  thread_id = Thread.current.object_id
  event = Event.new(name, @stacked_events[thread_id].last, payload)
  @stacked_events[thread_id] << event
  event
end

.endObject



22
23
24
25
26
27
28
# File 'lib/orchestra.rb', line 22

def end
  thread_id = Thread.current.object_id
  event = @stacked_events[thread_id].pop
  event.finish!
  publisher.push(event)
  event
end

.instrument(*args) ⇒ Object



30
31
32
33
34
# File 'lib/orchestra.rb', line 30

def instrument(*args)
  self.begin(*args)
  yield
  self.end
end