Skip to content

Instantly share code, notes, and snippets.

@greyblake
Created November 12, 2013 09:38
Show Gist options
  • Save greyblake/7428116 to your computer and use it in GitHub Desktop.
Save greyblake/7428116 to your computer and use it in GitHub Desktop.
class SocialNotifier
include Celluloid
attr_reader :status
def intialize(&block)
@block = block
end
def run
@status = @block.call
end
end
notifiers = [ SocialNotifier.new { model.send_to_twitter },
SocialNotifier.new { model.send_to_fb },
SocialNotifier.new { model.send_to_vk }
]
notifiers.each { |notifier| notifiers.async.run }
# Статус не будет возвращён, пока тред не завершит работу с методом run
notifiers.each do |notifier|
raise("Bla bla bla!") unless notifier.status == :ok
end
model.save!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment