-
Notifications
You must be signed in to change notification settings - Fork 36
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
Remove the AASM dependency #22
base: master
Are you sure you want to change the base?
Conversation
expect(subject).to be_open | ||
end | ||
|
||
if defined?(AASM::InvalidTransition) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good enough
@@ -1,3 +1,3 @@ | |||
module CircuitBreaker | |||
VERSION = '1.1.2' | |||
VERSION = '1.2.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✂️
Conflicts: lib/circuit_breaker/circuit_state.rb spec/circuit_breaker_spec.rb
@@ -0,0 +1,15 @@ | |||
class CircuitBreaker::InvalidTransition < RuntimeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally I wouldn't inherit from a runtime error, but it appears that's what aasm does https://github.com/rubyist/aasm/blob/a4bc27cff0d7b7fa5ef61e517555e17b82285254/lib/aasm/errors.rb
module AASM
class InvalidTransition < RuntimeError; end
class UndefinedState < RuntimeError; end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old code has all the extra methods on it
module AASM
class UnknownStateMachineError < RuntimeError; end
class InvalidTransition < RuntimeError
attr_reader :object, :event_name, :originating_state, :failures
def initialize(object, event_name, state_machine_name, failures = [])
@object, @event_name, @originating_state, @failures = object, event_name, object.aasm(state_machine_name).current_state, failures
super("Event '#{event_name}' cannot transition from '#{originating_state}'.#{reasoning}")
end
def reasoning
" Failed callback(s): #{failures}." unless failures.empty?
end
end
class UndefinedState < RuntimeError; end
class NoDirectAssignmentError < RuntimeError; end
end
Tested on Ruby 2.4 using wwtd
|
Extracted from #14