Class: Syncthing::Helper::API::DevicesUpdater
- Inherits:
-
UpdaterBase
- Object
- UpdaterBase
- Syncthing::Helper::API::DevicesUpdater
- Defined in:
- lib/syncthing/helper/api/updater.rb
Instance Attribute Summary
Attributes inherited from UpdaterBase
#config_obj, #current_snapshot, #listener
Instance Method Summary collapse
-
#devices_added ⇒ Object
(also: #devices_modified)
TODO: validate input!.
Methods inherited from UpdaterBase
#initialize, #listen, #removed
Constructor Details
This class inherits a constructor from Syncthing::Helper::API::UpdaterBase
Instance Method Details
#devices_added ⇒ Object Also known as: devices_modified
TODO: validate input!
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/syncthing/helper/api/updater.rb', line 42 def devices_added device_exists = @config_obj.devices.find{ |d| d['deviceID'] == @chng_obj.doc.document_id } unless device_exists new_device = @config_obj.devices.first.dup new_device['deviceID'] = @chng_obj.doc.document_id new_device['name'] = @chng_obj.doc.data[:label] new_device['compression'] = 'always' @config_obj.devices << new_device Logger.tagged('config_api: ' + @col.singularize + '/add') { Logger.debug @chng_obj.doc.document_id } end end |