Module: Evesync::Trigger::Base
Instance Method Summary collapse
- #ignore(ipc_data) ⇒ Object
- #process(message) ⇒ Object
-
#save_to_db(db, message) ⇒ Object
db must have a realization of save method.
-
#send_to_remotes(remotes, message) ⇒ Object
Every element in remotes must have a realization of handle method.
- #unignore(ipc_data) ⇒ Object
Instance Method Details
#ignore(ipc_data) ⇒ Object
39 40 41 42 |
# File 'lib/evesync/trigger/base.rb', line 39 def ignore(ipc_data) @ignore << ipc_data if ipc_data.is_a? data_class end |
#process(message) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/evesync/trigger/base.rb', line 27 def process() if ignore?() unignore() false else if save_to_db(@db, ) send_to_remotes(@remotes, ) true end end end |
#save_to_db(db, message) ⇒ Object
db must have a realization of save method
8 9 10 |
# File 'lib/evesync/trigger/base.rb', line 8 def save_to_db(db, ) db.save() end |
#send_to_remotes(remotes, message) ⇒ Object
Every element in remotes must have a realization of handle method
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/evesync/trigger/base.rb', line 14 def send_to_remotes(remotes, ) remotes.each do |evehand| begin Timeout.timeout(30) do # FIXME: take from Config evehand.handle() end rescue Timeout::Error Log.warn("Trigger remote timeout: server #{evehand.uri} " \ 'is not accessible') end end end |
#unignore(ipc_data) ⇒ Object
44 45 46 |
# File 'lib/evesync/trigger/base.rb', line 44 def unignore(ipc_data) @ignore.delete_if { |d| d == ipc_data } end |