Skip to content

Instantly share code, notes, and snippets.

@gnufied
Created June 29, 2013 09:38
Show Gist options
  • Save gnufied/5890545 to your computer and use it in GitHub Desktop.
Save gnufied/5890545 to your computer and use it in GitHub Desktop.
class Invite
add_state :accepted, :after => :accept_job
add_event(:accept) do
transitions :to => :accepted, :from => :pending
end
private
def accept_job
unless job.accept!
raise "Unable to accept job"
end
end
end
# Usage code:
Invite.transaction do
invite.accept!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment