Permalink
Browse files

Fix around_transition pausing not being marked as unsupported for rub…

…inius
  • Loading branch information...
1 parent 00ec068 commit 45550f8b9cabe1a87d568445e46a0d65ec2c8d2f @darkhelmet darkhelmet committed with obrie Feb 19, 2013
Showing with 11 additions and 4 deletions.
  1. +1 −0 CHANGELOG.md
  2. +7 −1 lib/state_machine/transition.rb
  3. +2 −2 test/unit/transition_collection_test.rb
  4. +1 −1 test/unit/transition_test.rb
View
@@ -1,5 +1,6 @@
# master
+* Fix around_transition pausing not being marked as unsupported for rubinius [Daniel Huckstep]
* Fix all / any / same matchers not being able to be used in :from / :to options in transitions and callbacks
* Fix ActiveModel locale paths not being loaded properly under certain JRuby environments [Brad Heller]
* Remove dependency on the validation_class_methods plugin for Sequel 2.12.0+ [Casey Howard]
@@ -84,6 +84,12 @@ class Transition
# Whether the transition is only existing temporarily for the object
attr_writer :transient
+ # Determines whether the curreny ruby implementation supports pausing and
+ # resuming transitions
+ def self.pause_supported?
+ RUBY_PLATFORM != 'java' && (!defined?(RUBY_ENGINE) || RUBY_ENGINE != 'rbx')
+ end
+
# Creates a new, specific transition
def initialize(object, machine, event, from_name, to_name, read_state = true) #:nodoc:
@object = object
@@ -355,7 +361,7 @@ def pausable
# around callbacks when the remainder of the callback will be executed at
# a later point in time.
def pause
- raise ArgumentError, 'around_transition callbacks cannot be called in multiple execution contexts in java implementations of Ruby. Use before/after_transitions instead.' if RUBY_PLATFORM == 'java'
+ raise ArgumentError, 'around_transition callbacks cannot be called in multiple execution contexts in java implementations of Ruby. Use before/after_transitions instead.' unless self.class.pause_supported?
unless @resume_block
require 'continuation' unless defined?(callcc)
@@ -1152,7 +1152,7 @@ def test_should_run_after_callbacks_on_subsequent_perform
end
end
-if RUBY_PLATFORM != 'java'
+if StateMachine::Transition.pause_supported?
class TransitionCollectionWithSkippedAfterCallbacksAndAroundCallbacksTest < Test::Unit::TestCase
def setup
@klass = Class.new
@@ -2137,7 +2137,7 @@ def test_should_marshal_during_after_callbacks
end
end
- if RUBY_PLATFORM != 'java'
+ if StateMachine::Transition.pause_supported?
def test_should_marshal_during_around_callbacks_before_yield
@machine.around_transition {|object, transition, block| Marshal.dump(object); block.call}
assert_nothing_raised do
@@ -1221,7 +1221,7 @@ def test_should_not_run_after_callbacks
assert !@run
end
- if RUBY_PLATFORM != 'java'
+ if StateMachine::Transition.pause_supported?
def test_should_run_around_callbacks_before_yield
@machine.around_transition {|block| @run = true; block.call}

0 comments on commit 45550f8

Please sign in to comment.