2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2003-06-18 11:45:12 -04:00
|
|
|
require 'observer'
|
|
|
|
|
|
|
|
module DRb
|
2013-01-24 22:25:39 -05:00
|
|
|
# The Observable module extended to DRb. See Observable for details.
|
2003-06-18 11:45:12 -04:00
|
|
|
module DRbObservable
|
|
|
|
include Observable
|
|
|
|
|
2013-01-24 22:25:39 -05:00
|
|
|
# Notifies observers of a change in state. See also
|
|
|
|
# Observable#notify_observers
|
2003-06-18 11:45:12 -04:00
|
|
|
def notify_observers(*arg)
|
|
|
|
if defined? @observer_state and @observer_state
|
2009-03-01 10:57:33 -05:00
|
|
|
if defined? @observer_peers
|
|
|
|
@observer_peers.each do |observer, method|
|
|
|
|
begin
|
2020-10-27 00:42:52 -04:00
|
|
|
observer.__send__(method, *arg)
|
2009-03-01 10:57:33 -05:00
|
|
|
rescue
|
|
|
|
delete_observer(observer)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@observer_state = false
|
2003-06-18 11:45:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|