Class: Diaspora::Federated::Generator

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/diaspora/federated/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, target) ⇒ Generator

Returns a new instance of Generator.


8
9
10
11
# File 'lib/diaspora/federated/generator.rb', line 8

def initialize(user, target)
  @user = user
  @target = target
end

Instance Method Details

#build(options = {}) ⇒ Object


22
23
24
# File 'lib/diaspora/federated/generator.rb', line 22

def build(options={})
  self.class.federated_class.new(options.merge(relayable_options).merge(author_id: @user.person.id))
end

#create!(options = {}) ⇒ Object


13
14
15
16
17
18
19
20
# File 'lib/diaspora/federated/generator.rb', line 13

def create!(options={})
  relayable = build(options)
  if relayable.save!
    logger.info "user:#{@user.id} dispatching #{relayable.class}:#{relayable.guid}"
    Diaspora::Federation::Dispatcher.defer_dispatch(@user, relayable)
    relayable
  end
end