Module: Semian::Instrumentable

Included in:
Semian
Defined in:
lib/semian/instrumentable.rb

Instance Method Summary collapse

Instance Method Details

#notify(*args) ⇒ Object



12
13
14
# File 'lib/semian/instrumentable.rb', line 12

def notify(*args)
  subscribers.values.each { |subscriber| subscriber.call(*args) }
end

#subscribe(name = rand, &block) ⇒ Object



3
4
5
6
# File 'lib/semian/instrumentable.rb', line 3

def subscribe(name = rand, &block)
  subscribers[name] = block
  name
end

#unsubscribe(name) ⇒ Object



8
9
10
# File 'lib/semian/instrumentable.rb', line 8

def unsubscribe(name)
  subscribers.delete(name)
end