Class: Hootenanny::Correspondent

Inherits:
Object
  • Object
show all
Defined in:
lib/hootenanny/correspondent.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic, options = {}) ⇒ Correspondent

Returns a new instance of Correspondent.



7
8
9
10
11
# File 'lib/hootenanny/correspondent.rb', line 7

def initialize(topic, options = {})
  self.topic              = topic
  self.synchronizer_class = options[:synchronizer] ||
                            Hootenanny.config.default_synchronizer
end

Class Method Details

.broadcast(topic, options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/hootenanny/correspondent.rb', line 13

def self.broadcast(topic, options = {})
  correspondent = new(topic, options = {})

  correspondent.broadcast
end

Instance Method Details

#broadcastObject



19
20
21
22
23
24
25
# File 'lib/hootenanny/correspondent.rb', line 19

def broadcast
  subscriptions.all? do |subscription|
    synchronizer_class.sync(subscriber:    subscription.subscriber,
                            digest_secret: subscription.digest_secret,
                            topic:         topic.url)
  end
end