class Syncthing::Helper::API::UpdaterBase
Attributes
config_obj[RW]
current_snapshot[RW]
listener[RW]
Public Class Methods
new(config_obj: nil, col: nil)
click to toggle source
Calls superclass method
# File lib/syncthing/helper/api/updater.rb, line 8 def initialize config_obj: nil, col: nil super() @config_obj = config_obj @col = col listen end
Public Instance Methods
listen()
click to toggle source
# File lib/syncthing/helper/api/updater.rb, line 15 def listen Logger.tagged('firestore/' + @col) {Logger.info 'Starting query listener'} @listener = (Firestore.col @col).listen do |snapshot| if snapshot.changes.count > 0 @config_obj.retrieve @current_snapshot = snapshot snapshot.changes.each do |chng| @chng_obj = chng send "#{@col}_#{chng.type.to_s}".to_sym end @config_obj.update Logger.tagged('config_api: ' + @col.singularize + '/update') { Logger.debug 'Written' } end end end
removed()
click to toggle source
# File lib/syncthing/helper/api/updater.rb, line 31 def removed id_field = API::DB_FIELDS_CONFIG_OBJ[@col] @config_obj[@col].delete_if { |f| f[id_field] == @chng_obj.doc.document_id } Logger.tagged('config_api: ' + @col.singularize + '/rm') { Logger.debug @chng_obj.doc.document_id } end
Also aliased as: folders_removed, devices_removed