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