Class: Federated::Generator

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

Instance Method Summary collapse

Constructor Details

#initialize(user, target) ⇒ Generator


3
4
5
6
# File 'lib/federated/generator.rb', line 3

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

Instance Method Details

#build(options = {}) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/federated/generator.rb', line 17

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

#create!(options = {}) ⇒ Object


8
9
10
11
12
13
14
15
# File 'lib/federated/generator.rb', line 8

def create!(options={})
  relayable = build(options)
  if relayable.save!
    FEDERATION_LOGGER.info("user:#{@user.id} dispatching #{relayable.class}:#{relayable.guid}")
    Postzord::Dispatcher.defer_build_and_post(@user, relayable)
    relayable
  end
end