Skip to content

Instantly share code, notes, and snippets.

@kevinrutherford
Created July 6, 2012 15:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kevinrutherford/3060969 to your computer and use it in GitHub Desktop.
Railsy callback style
class PublishesPosts < Struct.new(:post_id, :ui)
def run
Blog.lookup_post(post_id) do |result|
result.success => lambda {|post| post.publish; ui.post_published(post) },
result.failure => lambda {|post_id| ui.no_such_post(post_id) })
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment