Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a block to be called when running a transition #90

Merged
merged 1 commit into from
Nov 18, 2013

Conversation

Intrepidd
Copy link
Contributor

Hi,

This is based on the former run_transition method of the old acts_as_state_machine gem from @rubyist

Sometimes, you want to do an action only if the transition succeeds, but you also want to call the failed callbacks when it does not.

I did not find any way to do this natively (feel free to point out some existing ways if there are), so I implemented this little feature.

object.transition! do
  some_code
end

some_code will be called only if the transition succeeds, before launching the after_enter callbacks.

@coveralls
Copy link

Coverage Status

Coverage increased (+3.1%) when pulling 46878f9 on Intrepidd:master into 8a14cac on aasm:master.

@ghost ghost assigned alto Sep 5, 2013
@Intrepidd
Copy link
Contributor Author

Hey ! Any news ?

@alto alto merged commit 46878f9 into aasm:master Nov 18, 2013
@alto
Copy link
Member

alto commented Nov 18, 2013

Sorry for the delay. I just saw the merge conflict and put it back without taking a closer look. At the end, it was pretty easy. Thanks a lot for the nice change!

Do you mind adding some lines to the readme? I'm happy to release a new version then. Let me know if you want to update the readme. Otherwise I'll come up with information about the new possibility.

@Intrepidd
Copy link
Contributor Author

No problem !

I'll issue a new PR shortly with README changes :)

Intrepidd added a commit to Intrepidd/aasm that referenced this pull request Nov 19, 2013
@Intrepidd
Copy link
Contributor Author

See #97 !

alto added a commit that referenced this pull request Nov 20, 2013
Add README changes for pull request #90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants