Class: Diaspora::Federation::Dispatcher

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/diaspora/federation/dispatcher.rb,
lib/diaspora/federation/dispatcher/public.rb,
lib/diaspora/federation/dispatcher/private.rb

Direct Known Subclasses

Private, Public

Defined Under Namespace

Classes: Private, Public

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sender, object, opts = {}) ⇒ Dispatcher

Returns a new instance of Dispatcher.


8
9
10
11
12
# File 'lib/diaspora/federation/dispatcher.rb', line 8

def initialize(sender, object, opts={})
  @sender = sender
  @object = object
  @opts = opts
end

Class Method Details

.build(sender, object, opts = {}) ⇒ Object


14
15
16
17
18
19
20
21
# File 'lib/diaspora/federation/dispatcher.rb', line 14

def self.build(sender, object, opts={})
  sender = object.try(:sender_for_dispatch) || sender
  if object.try(:public?)
    Public.new(sender, object, opts)
  else
    Private.new(sender, object, opts)
  end
end

.defer_dispatch(sender, object, opts = {}) ⇒ Object


23
24
25
# File 'lib/diaspora/federation/dispatcher.rb', line 23

def self.defer_dispatch(sender, object, opts={})
  Workers::DeferredDispatch.perform_async(sender.id, object.class.to_s, object.id, opts)
end

Instance Method Details

#dispatchObject


27
28
29
30
# File 'lib/diaspora/federation/dispatcher.rb', line 27

def dispatch
  deliver_to_services
  deliver_to_subscribers
end