mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Remove explicit after_commit_action
dependency
This commit is contained in:
parent
838428c6e4
commit
19406b27b4
13 changed files with 28 additions and 9 deletions
|
@ -55,7 +55,9 @@ appraise 'rails_5.2' do
|
|||
end
|
||||
|
||||
appraise 'norails' do
|
||||
gem 'sqlite3', '~> 1.3', '>= 1.3.5', platforms: :ruby
|
||||
gem 'rails', install_if: false
|
||||
gem 'after_commit_action', install_if: false
|
||||
gem 'sequel'
|
||||
gem 'redis-objects'
|
||||
end
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -4,3 +4,4 @@ gemspec
|
|||
|
||||
gem 'sqlite3', '~> 1.3.5', :platforms => :ruby
|
||||
gem 'rails', '5.1.4'
|
||||
gem 'after_commit_action', '~> 1.0'
|
||||
|
|
|
@ -981,6 +981,12 @@ job.run
|
|||
job.save! #notify_about_running_job is not run
|
||||
```
|
||||
|
||||
Please note that `:after_commit` AASM callbacks behaves around custom implementation
|
||||
of transaction pattern rather than a real-life DB transaction. This fact still causes
|
||||
the race conditions and redundant callback calls within nested transaction. In order
|
||||
to fix that it's highly recommended to add `gem 'after_commit_action', '~> 1.0'` to your
|
||||
`Gemfile`.
|
||||
|
||||
If you want to encapsulate state changes within an own transaction, the behavior
|
||||
of this nested transaction might be confusing. Take a look at
|
||||
[ActiveRecord Nested Transactions](http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html)
|
||||
|
|
|
@ -17,7 +17,6 @@ Gem::Specification.new do |s|
|
|||
s.required_ruby_version = '>= 1.9.3'
|
||||
|
||||
s.add_dependency 'concurrent-ruby', '~> 1.0'
|
||||
s.add_dependency 'after_commit_action', '~> 1.0'
|
||||
|
||||
s.add_development_dependency 'rake'
|
||||
s.add_development_dependency 'sdoc'
|
||||
|
|
|
@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
gem "sqlite3", "~> 1.3", ">= 1.3.5", platforms: :ruby
|
||||
gem "rails", install_if: false
|
||||
gem "after_commit_action", install_if: false
|
||||
gem "sequel"
|
||||
gem "redis-objects"
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
gem "sqlite3", "~> 1.3.5", platforms: :ruby
|
||||
gem "rails", "4.2.5"
|
||||
gem "after_commit_action", "~> 1.0"
|
||||
gem "nokogiri", "1.6.8.1", platforms: [:ruby_19]
|
||||
gem "mime-types", "~> 2", platforms: [:ruby_19, :jruby]
|
||||
gem "mongoid", "~> 4.0"
|
||||
|
|
|
@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
gem "sqlite3", "~> 1.3.5", platforms: :ruby
|
||||
gem "rails", "4.2.5"
|
||||
gem "after_commit_action", "~> 1.0"
|
||||
gem "mime-types", "~> 2", platforms: [:ruby_19, :jruby]
|
||||
gem "mongoid", "~> 5.0"
|
||||
gem "activerecord-jdbcsqlite3-adapter", "1.3.24", platforms: :jruby
|
||||
|
|
|
@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
gem "sqlite3", "~> 1.3.5", platforms: :ruby
|
||||
gem "rails", "4.2.5"
|
||||
gem "after_commit_action", "~> 1.0"
|
||||
gem "nobrainer", "~> 0.33.0"
|
||||
|
||||
gemspec path: "../"
|
||||
|
|
|
@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
gem "sqlite3", "~> 1.3.5", platforms: :ruby
|
||||
gem "rails", "5.0.0"
|
||||
gem "after_commit_action", "~> 1.0"
|
||||
gem "mongoid", "~> 6.0"
|
||||
gem "sequel"
|
||||
gem "dynamoid", "~> 1.3", platforms: :ruby
|
||||
|
|
|
@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
gem "sqlite3", "~> 1.3.5", platforms: :ruby
|
||||
gem "rails", "5.0.0"
|
||||
gem "after_commit_action", "~> 1.0"
|
||||
gem "nobrainer", "~> 0.33.0"
|
||||
|
||||
gemspec path: "../"
|
||||
|
|
|
@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
gem "sqlite3", "~> 1.3.5", platforms: :ruby
|
||||
gem "rails", "5.1"
|
||||
gem "after_commit_action", "~> 1.0"
|
||||
gem "mongoid", "~>6.0"
|
||||
gem "sequel"
|
||||
gem "dynamoid", "~> 1.3", platforms: :ruby
|
||||
|
|
|
@ -4,6 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
gem "sqlite3", "~> 1.3.5", platforms: :ruby
|
||||
gem "rails", "5.2"
|
||||
gem "after_commit_action", "~> 1.0"
|
||||
gem "mongoid", "~>6.0"
|
||||
gem "sequel"
|
||||
gem "dynamoid", "~>2.2", platforms: :ruby
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
require 'after_commit_action'
|
||||
require 'aasm/persistence/orm'
|
||||
module AASM
|
||||
module Persistence
|
||||
|
@ -29,7 +28,17 @@ module AASM
|
|||
# end
|
||||
#
|
||||
def self.included(base)
|
||||
base.send(:include, ::AfterCommitAction) unless base.include?(::AfterCommitAction)
|
||||
begin
|
||||
require 'after_commit_action'
|
||||
base.send(:include, ::AfterCommitAction) unless base.include?(::AfterCommitAction)
|
||||
base.send(:alias_method, :aasm_execute_after_commit, :execute_after_commit)
|
||||
rescue LoadError
|
||||
warn <<-MSG
|
||||
[DEPRECATION] :after_commit AASM callback is not safe in terms of race conditions and redundant calls.
|
||||
Please add `gem 'after_commit_action', '~> 1.0'` to your Gemfile in order to fix that.
|
||||
MSG
|
||||
end
|
||||
|
||||
base.send(:include, AASM::Persistence::Base)
|
||||
base.send(:include, AASM::Persistence::ORM)
|
||||
base.send(:include, AASM::Persistence::ActiveRecordPersistence::InstanceMethods)
|
||||
|
@ -90,12 +99,6 @@ module AASM
|
|||
end
|
||||
end
|
||||
|
||||
def aasm_execute_after_commit
|
||||
execute_after_commit do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
def aasm_enum(name=:default)
|
||||
case AASM::StateMachineStore.fetch(self.class, true).machine(name).config.enum
|
||||
when false then nil
|
||||
|
|
Loading…
Reference in a new issue