Commit a6a88ffb

mo khan <mo@mokhan.ca>
2015-01-17 19:36:43
use new job to publish a tweet about a new cake.
1 parent b0fb328
Changed files (1)
app
services
app/services/application/create_cake_command.rb
@@ -1,8 +1,7 @@
 class CreateCakeCommand
-  def initialize(context, current_user = context.current_user, command_bus = Spank::IOC.resolve(:command_bus))
+  def initialize(context, current_user = context.current_user)
     @context = context
     @current_user = current_user
-    @command_bus = command_bus
   end
 
   def run(attributes, tags)
@@ -10,7 +9,7 @@ class CreateCakeCommand
     @current_user.tag(cake, with: tags, on: :tags)
 
     if cake.save
-      @command_bus.publish(:cake_published, cake_id: cake.id)
+      PublishToTwitterJob.set(wait_until: 1.hour.from_now).perform_later(cake)
       @context.create_cake_succeeded(cake)
     else
       @context.create_cake_failed(cake)