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

Remove the AASM dependency #22

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

bf4
Copy link

@bf4 bf4 commented Dec 17, 2018

Extracted from #14

expect(subject).to be_open
end

if defined?(AASM::InvalidTransition)
Copy link
Author

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'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️

yurivm and others added 2 commits December 17, 2018 10:49
Conflicts:
	lib/circuit_breaker/circuit_state.rb
	spec/circuit_breaker_spec.rb
@@ -0,0 +1,15 @@
class CircuitBreaker::InvalidTransition < RuntimeError
Copy link
Author

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

Copy link
Author

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

https://github.com/aasm/aasm/blob/35d6f6843f48760a1e719b507cc832f1a683127f/lib/aasm/errors.rb

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

@bf4
Copy link
Author

bf4 commented Dec 17, 2018

Tested on Ruby 2.4 using wwtd

gem install wwtd
wwtd

@yurivm yurivm mentioned this pull request Dec 17, 2018
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.

2 participants