Class: Artery::Sync
- Inherits:
-
Object
- Object
- Artery::Sync
- Defined in:
- lib/artery/sync.rb
Instance Attribute Summary collapse
-
#sync_id ⇒ Object
Returns the value of attribute sync_id.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(services = nil) ⇒ Object
-
#initialize(sync_id) ⇒ Sync
constructor
A new instance of Sync.
Constructor Details
#initialize(sync_id) ⇒ Sync
Returns a new instance of Sync.
7 8 9 |
# File 'lib/artery/sync.rb', line 7 def initialize(sync_id) @sync_id = sync_id end |
Instance Attribute Details
#sync_id ⇒ Object
Returns the value of attribute sync_id.
5 6 7 |
# File 'lib/artery/sync.rb', line 5 def sync_id @sync_id end |
Class Method Details
Instance Method Details
#execute(services = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/artery/sync.rb', line 11 def execute(services = nil) services = Array.wrap(services).map(&:to_sym) subscriptions_on_services = services.blank? ? Artery.subscriptions : Artery.subscriptions_on(services) if subscriptions_on_services.blank? Artery.logger.warn 'No suitable subscriptions defined, exiting...' return end @sync_fiber = Fiber.new do # all synchronization inside must be synchronous subscriptions_on_services.values.flatten.uniq.each(&:synchronize!) end @sync_fiber.resume end |