Skip to content

Instantly share code, notes, and snippets.

@pote
Created March 8, 2013 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pote/5113400 to your computer and use it in GitHub Desktop.
Save pote/5113400 to your computer and use it in GitHub Desktop.
Promises are Futures.
require 'celluloid'
class Politician
include Celluloid
def lower_taxes
# Try really hard to do this
result_of_complicated_code = [true, false].sample
yield result_of_complicated_code
end
end
some_dude = Politician.new
promise = some_dude.future.lower_taxes do |result|
result ? 'this was successful' : 'this was unsuccessful'
end
puts promise.value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment