after_commit_action 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -5
- data/Gemfile.lock +2 -69
- data/README.md +1 -0
- data/Rakefile +0 -2
- data/VERSION +1 -1
- data/after_commit_action.gemspec +10 -10
- data/lib/after_commit_action.rb +23 -36
- data/spec/models/tester.rb +3 -1
- data/spec/rails_app/config/application.rb +0 -6
- data/spec/rails_app/config/environments/development.rb +0 -7
- data/spec/rails_app/config/environments/production.rb +0 -4
- data/spec/rails_app/config/environments/test.rb +0 -3
- data/spec/spec_helper.rb +0 -6
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7098526c08593ab256447fbe799f786c877e4831
|
4
|
+
data.tar.gz: c090670e06e2edc562ffea54df197ffd9f947abb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a89dfaec4db205f167749d6d8b49c9a419352c9ef70f7f2fb4c89c118e55c50a7539dd391ea25147ff2c3982b067860160ac6e7de97f1503336a01f0a41f8688
|
7
|
+
data.tar.gz: 2505e04c3e9dc9e18263180925be6d8617d1b936adc8066e698a05e9eb6113e814fc93c62bb84ebfceca3294390a99d9dc42f749b3f9a0280da5ec4b9b0d242c
|
data/Gemfile
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
group :development, :test do
|
6
|
-
gem "rails"
|
7
|
-
end
|
3
|
+
gem "activerecord", ">= 3.0.0"
|
4
|
+
gem "activesupport", ">= 3.0.0"
|
8
5
|
|
9
6
|
group :development do
|
10
7
|
gem "rdoc", "~> 3.12"
|
data/Gemfile.lock
CHANGED
@@ -1,28 +1,6 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (4.2.0)
|
5
|
-
actionpack (= 4.2.0)
|
6
|
-
actionview (= 4.2.0)
|
7
|
-
activejob (= 4.2.0)
|
8
|
-
mail (~> 2.5, >= 2.5.4)
|
9
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
10
|
-
actionpack (4.2.0)
|
11
|
-
actionview (= 4.2.0)
|
12
|
-
activesupport (= 4.2.0)
|
13
|
-
rack (~> 1.6.0)
|
14
|
-
rack-test (~> 0.6.2)
|
15
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
17
|
-
actionview (4.2.0)
|
18
|
-
activesupport (= 4.2.0)
|
19
|
-
builder (~> 3.1)
|
20
|
-
erubis (~> 2.7.0)
|
21
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
23
|
-
activejob (4.2.0)
|
24
|
-
activesupport (= 4.2.0)
|
25
|
-
globalid (>= 0.3.0)
|
26
4
|
activemodel (4.2.0)
|
27
5
|
activesupport (= 4.2.0)
|
28
6
|
builder (~> 3.1)
|
@@ -42,7 +20,6 @@ GEM
|
|
42
20
|
descendants_tracker (0.0.4)
|
43
21
|
thread_safe (~> 0.3, >= 0.3.1)
|
44
22
|
diff-lcs (1.1.3)
|
45
|
-
erubis (2.7.0)
|
46
23
|
faraday (0.9.0)
|
47
24
|
multipart-post (>= 1.2, < 3)
|
48
25
|
git (1.2.8)
|
@@ -54,11 +31,8 @@ GEM
|
|
54
31
|
multi_json (>= 1.7.5, < 2.0)
|
55
32
|
nokogiri (~> 1.6.3)
|
56
33
|
oauth2
|
57
|
-
globalid (0.3.0)
|
58
|
-
activesupport (>= 4.1.0)
|
59
34
|
hashie (3.3.2)
|
60
35
|
highline (1.6.21)
|
61
|
-
hike (1.2.3)
|
62
36
|
i18n (0.7.0)
|
63
37
|
jeweler (2.0.1)
|
64
38
|
builder
|
@@ -71,11 +45,6 @@ GEM
|
|
71
45
|
rdoc
|
72
46
|
json (1.8.1)
|
73
47
|
jwt (1.2.0)
|
74
|
-
loofah (2.0.1)
|
75
|
-
nokogiri (>= 1.5.9)
|
76
|
-
mail (2.6.3)
|
77
|
-
mime-types (>= 1.16, < 3)
|
78
|
-
mime-types (2.4.3)
|
79
48
|
mini_portile (0.6.1)
|
80
49
|
minitest (5.5.0)
|
81
50
|
multi_json (1.10.1)
|
@@ -90,32 +59,6 @@ GEM
|
|
90
59
|
multi_xml (~> 0.5)
|
91
60
|
rack (~> 1.2)
|
92
61
|
rack (1.6.0)
|
93
|
-
rack-test (0.6.2)
|
94
|
-
rack (>= 1.0)
|
95
|
-
rails (4.2.0)
|
96
|
-
actionmailer (= 4.2.0)
|
97
|
-
actionpack (= 4.2.0)
|
98
|
-
actionview (= 4.2.0)
|
99
|
-
activejob (= 4.2.0)
|
100
|
-
activemodel (= 4.2.0)
|
101
|
-
activerecord (= 4.2.0)
|
102
|
-
activesupport (= 4.2.0)
|
103
|
-
bundler (>= 1.3.0, < 2.0)
|
104
|
-
railties (= 4.2.0)
|
105
|
-
sprockets-rails
|
106
|
-
rails-deprecated_sanitizer (1.0.3)
|
107
|
-
activesupport (>= 4.2.0.alpha)
|
108
|
-
rails-dom-testing (1.0.5)
|
109
|
-
activesupport (>= 4.2.0.beta, < 5.0)
|
110
|
-
nokogiri (~> 1.6.0)
|
111
|
-
rails-deprecated_sanitizer (>= 1.0.1)
|
112
|
-
rails-html-sanitizer (1.0.1)
|
113
|
-
loofah (~> 2.0)
|
114
|
-
railties (4.2.0)
|
115
|
-
actionpack (= 4.2.0)
|
116
|
-
activesupport (= 4.2.0)
|
117
|
-
rake (>= 0.8.7)
|
118
|
-
thor (>= 0.18.1, < 2.0)
|
119
62
|
rake (10.4.2)
|
120
63
|
rdoc (3.12.2)
|
121
64
|
json (~> 1.4)
|
@@ -128,19 +71,8 @@ GEM
|
|
128
71
|
diff-lcs (~> 1.1.2)
|
129
72
|
rspec-extra-formatters (1.0.0)
|
130
73
|
rspec-mocks (2.8.0)
|
131
|
-
sprockets (2.12.3)
|
132
|
-
hike (~> 1.2)
|
133
|
-
multi_json (~> 1.0)
|
134
|
-
rack (~> 1.0)
|
135
|
-
tilt (~> 1.1, != 1.3.0)
|
136
|
-
sprockets-rails (2.2.2)
|
137
|
-
actionpack (>= 3.0)
|
138
|
-
activesupport (>= 3.0)
|
139
|
-
sprockets (>= 2.8, < 4.0)
|
140
74
|
sqlite3 (1.3.10)
|
141
|
-
thor (0.19.1)
|
142
75
|
thread_safe (0.3.4)
|
143
|
-
tilt (1.4.1)
|
144
76
|
tzinfo (1.2.2)
|
145
77
|
thread_safe (~> 0.1)
|
146
78
|
|
@@ -148,9 +80,10 @@ PLATFORMS
|
|
148
80
|
ruby
|
149
81
|
|
150
82
|
DEPENDENCIES
|
83
|
+
activerecord (>= 3.0.0)
|
84
|
+
activesupport (>= 3.0.0)
|
151
85
|
bundler (>= 1.1.3)
|
152
86
|
jeweler (~> 2.0.1)
|
153
|
-
rails
|
154
87
|
rdoc (~> 3.12)
|
155
88
|
rspec (~> 2.8.0)
|
156
89
|
rspec-extra-formatters
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -21,8 +21,6 @@ Jeweler::Tasks.new do |gem|
|
|
21
21
|
gem.description = %Q{Use this module to defer actions to the after-commit hook. This is useful if you want to trigger actions in after_create, after_destroy and after_update callbacks but want to execute them outside of the transaction (for example, to avoid deadlocks).}
|
22
22
|
gem.email = "magnus@bestvendor.com"
|
23
23
|
gem.authors = ["BestVendor"]
|
24
|
-
|
25
|
-
gem.add_dependency 'activerecord', '>= 3.0.0'
|
26
24
|
end
|
27
25
|
Jeweler::RubygemsDotOrgTasks.new
|
28
26
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/after_commit_action.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: after_commit_action 0.
|
5
|
+
# stub: after_commit_action 1.0.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "after_commit_action"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "1.0.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["BestVendor"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2015-03-07"
|
15
15
|
s.description = "Use this module to defer actions to the after-commit hook. This is useful if you want to trigger actions in after_create, after_destroy and after_update callbacks but want to execute them outside of the transaction (for example, to avoid deadlocks)."
|
16
16
|
s.email = "magnus@bestvendor.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -87,31 +87,31 @@ Gem::Specification.new do |s|
|
|
87
87
|
]
|
88
88
|
s.homepage = "http://github.com/magnusvk/after_commit_action"
|
89
89
|
s.licenses = ["MIT"]
|
90
|
-
s.rubygems_version = "2.
|
90
|
+
s.rubygems_version = "2.4.3"
|
91
91
|
s.summary = "Easily defer blocks of code to the after-commit action of an ActiveRecord model."
|
92
92
|
|
93
93
|
if s.respond_to? :specification_version then
|
94
94
|
s.specification_version = 4
|
95
95
|
|
96
96
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
97
|
-
s.
|
97
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
|
98
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
|
98
99
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
99
100
|
s.add_development_dependency(%q<bundler>, [">= 1.1.3"])
|
100
101
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
101
|
-
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
|
102
102
|
else
|
103
|
-
s.add_dependency(%q<
|
103
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
104
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
104
105
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
105
106
|
s.add_dependency(%q<bundler>, [">= 1.1.3"])
|
106
107
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
107
|
-
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
108
108
|
end
|
109
109
|
else
|
110
|
-
s.add_dependency(%q<
|
110
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
111
|
+
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
111
112
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
112
113
|
s.add_dependency(%q<bundler>, [">= 1.1.3"])
|
113
114
|
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
114
|
-
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
data/lib/after_commit_action.rb
CHANGED
@@ -7,49 +7,36 @@
|
|
7
7
|
# def my_hook
|
8
8
|
# execute_after_commit { puts "This is called after committing the transaction. "}
|
9
9
|
# end
|
10
|
+
require 'active_support/concern'
|
10
11
|
|
11
12
|
module AfterCommitAction
|
13
|
+
extend ActiveSupport::Concern
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
base.after_commit :_after_commit_hook
|
17
|
-
end
|
18
|
-
|
19
|
-
def execute_after_commit(&block)
|
20
|
-
@_execute_after_commit ||= []
|
21
|
-
@_execute_after_commit<< block
|
22
|
-
end
|
23
|
-
|
24
|
-
def _after_commit_hook
|
25
|
-
begin
|
26
|
-
until @_execute_after_commit.blank?
|
27
|
-
@_execute_after_commit.shift.call
|
28
|
-
end
|
29
|
-
rescue => e
|
30
|
-
if defined?(Exceptional)
|
31
|
-
# Rails quietly swallows exceptions in after-commit actions; to avoid missing these
|
32
|
-
# exceptions, we pass them to Exceptional explicitly
|
33
|
-
Exceptional.context(:after_commit_entity => self.inspect)
|
34
|
-
Exceptional.handle(e, "execute_after_commit")
|
35
|
-
else
|
36
|
-
Rails.logger.error "Error in execute_after_commit block: #{e.inspect}"
|
37
|
-
end
|
38
|
-
raise e
|
39
|
-
end
|
40
|
-
end
|
15
|
+
included do
|
16
|
+
after_commit :_after_commit_hook
|
17
|
+
end
|
41
18
|
|
19
|
+
def execute_after_commit(&block)
|
20
|
+
@_execute_after_commit ||= []
|
21
|
+
@_execute_after_commit<< block
|
42
22
|
end
|
43
23
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
::ActiveRecord::Base.send :include, ActiveRecord
|
49
|
-
end
|
24
|
+
def _after_commit_hook
|
25
|
+
begin
|
26
|
+
until @_execute_after_commit.blank?
|
27
|
+
@_execute_after_commit.shift.call
|
50
28
|
end
|
29
|
+
rescue => e
|
30
|
+
if defined?(Exceptional)
|
31
|
+
# Rails quietly swallows exceptions in after-commit actions; to avoid missing these
|
32
|
+
# exceptions, we pass them to Exceptional explicitly
|
33
|
+
Exceptional.context(:after_commit_entity => self.inspect)
|
34
|
+
Exceptional.handle(e, "execute_after_commit")
|
35
|
+
else
|
36
|
+
Rails.logger.error "Error in execute_after_commit block: #{e.inspect}"
|
37
|
+
end
|
38
|
+
raise e
|
51
39
|
end
|
52
|
-
else
|
53
|
-
::ActiveRecord::Base.send :include, ActiveRecord
|
54
40
|
end
|
41
|
+
|
55
42
|
end
|
data/spec/models/tester.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class Tester < ActiveRecord::Base
|
2
|
+
include AfterCommitAction
|
3
|
+
|
2
4
|
after_initialize :after_initialize
|
3
5
|
|
4
6
|
before_create :before_create
|
@@ -15,7 +17,7 @@ class Tester < ActiveRecord::Base
|
|
15
17
|
def before_create
|
16
18
|
execute_after_commit { @array<< 'before_create' }
|
17
19
|
end
|
18
|
-
|
20
|
+
|
19
21
|
def after_create
|
20
22
|
execute_after_commit { @array<< 'after_create' }
|
21
23
|
end
|
@@ -44,12 +44,6 @@ module RailsApp
|
|
44
44
|
# like if you have constraints or database-specific column types
|
45
45
|
# config.active_record.schema_format = :sql
|
46
46
|
|
47
|
-
# Enforce whitelist mode for mass assignment.
|
48
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
49
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
50
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
51
|
-
config.active_record.whitelist_attributes = true
|
52
|
-
|
53
47
|
# Enable the asset pipeline
|
54
48
|
config.assets.enabled = true
|
55
49
|
|
@@ -22,13 +22,6 @@ RailsApp::Application.configure do
|
|
22
22
|
# Only use best-standards-support built into browsers
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
24
24
|
|
25
|
-
# Raise exception on mass assignment protection for Active Record models
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
-
|
28
|
-
# Log the query plan for queries taking more than this (works
|
29
|
-
# with SQLite, MySQL, and PostgreSQL)
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
-
|
32
25
|
# Do not compress assets
|
33
26
|
config.assets.compress = false
|
34
27
|
|
@@ -60,8 +60,4 @@ RailsApp::Application.configure do
|
|
60
60
|
|
61
61
|
# Send deprecation notices to registered listeners
|
62
62
|
config.active_support.deprecation = :notify
|
63
|
-
|
64
|
-
# Log the query plan for queries taking more than this (works
|
65
|
-
# with SQLite, MySQL, and PostgreSQL)
|
66
|
-
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
67
63
|
end
|
@@ -29,9 +29,6 @@ RailsApp::Application.configure do
|
|
29
29
|
# ActionMailer::Base.deliveries array.
|
30
30
|
config.action_mailer.delivery_method = :test
|
31
31
|
|
32
|
-
# Raise exception on mass assignment protection for Active Record models
|
33
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
34
|
-
|
35
32
|
# Print deprecation notices to the stderr
|
36
33
|
config.active_support.deprecation = :stderr
|
37
34
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -10,9 +10,3 @@ load "#{File.dirname(__FILE__)}/schema.rb"
|
|
10
10
|
# Requires supporting files with custom matchers and macros, etc,
|
11
11
|
# in ./support/ and its subdirectories.
|
12
12
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
13
|
-
|
14
|
-
RSpec.configure do |config|
|
15
|
-
config.before :suite do
|
16
|
-
ActiveRecord::Base.send :include, AfterCommitAction::ActiveRecord
|
17
|
-
end
|
18
|
-
end
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: after_commit_action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BestVendor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: 3.0.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rdoc
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +80,6 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 2.0.1
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: activerecord
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 3.0.0
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 3.0.0
|
83
83
|
description: Use this module to defer actions to the after-commit hook. This is useful
|
84
84
|
if you want to trigger actions in after_create, after_destroy and after_update callbacks
|
85
85
|
but want to execute them outside of the transaction (for example, to avoid deadlocks).
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.4.3
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Easily defer blocks of code to the after-commit action of an ActiveRecord
|