Class: Sysdo::EventSource

Inherits:
Object
  • Object
show all
Defined in:
lib/sysdo/event_source.rb,
lib/sysdo/event_source/polled_change.rb,
lib/sysdo/event_source/polled_equal_change.rb,
lib/sysdo/event_source/polled_collection_change.rb

Defined Under Namespace

Classes: PolledChange, PolledCollectionChange, PolledEqualChange

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&listener) ⇒ EventSource

Returns a new instance of EventSource.



5
6
7
8
# File 'lib/sysdo/event_source.rb', line 5

def initialize(&listener)
  @listener = listener
  @on_fire = ->{}
end

Instance Attribute Details

#on_fireObject

Returns the value of attribute on_fire.



3
4
5
# File 'lib/sysdo/event_source.rb', line 3

def on_fire
  @on_fire
end

Instance Method Details

#fire(*args, **kwargs) ⇒ Object



10
11
12
# File 'lib/sysdo/event_source.rb', line 10

def fire(*args, **kwargs)
  @on_fire.(*args, **kwargs)
end

#listenObject



14
15
16
17
# File 'lib/sysdo/event_source.rb', line 14

def listen
  @listener.(self)
  # TODO: what if this dies?
end