Module: Brainguy::Observable

Extended by:
Forwardable
Defined in:
lib/brainguy/observable.rb

Overview

A convenience module for making client classes observable.

Instance Method Summary collapse

Instance Method Details

#eventsEmitter


11
12
13
# File 'lib/brainguy/observable.rb', line 11

def events
  @brainguy_subscriptions ||= Emitter.new(self)
end

#on(name_or_handlers, &block) ⇒ Object

(see Emitter#on)


26
# File 'lib/brainguy/observable.rb', line 26

def_delegator :events, :on

#with_subscription_scope(listener_block, &block) ⇒ Object

Create a temporary scope for transient subscriptions. Useful for making a single method listenable. See README for usage examples.


20
21
22
# File 'lib/brainguy/observable.rb', line 20

def with_subscription_scope(listener_block, &block)
  Brainguy.with_subscription_scope(self, listener_block, events, &block)
end