deferring 0.4.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dd86f3cc417a4a3415ae6ea1ef923d04fc48bb8b
4
- data.tar.gz: 817f111436c5ed093bc65cd212a36b4a94a76f97
2
+ SHA256:
3
+ metadata.gz: b06d2014bec77285df7d494e04b1aceae86e4ce9b147f0916002db02e1e79cba
4
+ data.tar.gz: d89af52998b5d67de9f29cf971a5f68f1ce9339e340f3170c9c0cbd6c4df1713
5
5
  SHA512:
6
- metadata.gz: 91f7c54cbddfec3c1c72b131a44836b0d5acccaf4a8c35e809412acd5efb28493b65a826ffb036ea805c09ded7bba851b6857ffc586371124620d8767f9e5949
7
- data.tar.gz: 67a25d6daaa8d0977e0e88a395e00f1b7f9abe67b849a7dc53892036f8f4f3d0546c4f3c61ef22744efb7ac8ba6d75a09c366a8fbfef9857678278760d2f92ed
6
+ metadata.gz: 3fd88c4d8a0c1be57f6b4ac674faf39bc1a152117a86d719aa6e2727cd93b916d547404e66c5e67f636aeb209918a0dcbcf78db256704ff3e45c0f9951c592ca
7
+ data.tar.gz: 15ac8fa0e41d23af97a1ac35ac0e29c429e1287bc83fa6cf7148437070a57a6bd8a36fa49910bc5d8ee4288d2ca20c091ac7289b63b210e2c13d4db4997453a8
@@ -1,29 +1,26 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.3.0
5
- - 2.3.3
6
- - 2.4.0
7
- - ruby-head
4
+ - 2.3.8
5
+ - 2.4.6
6
+ - 2.5.5
7
+ - 2.6.3
8
+ - 2.7.1
8
9
 
9
10
  gemfile:
10
- - gemfiles/rails_40.gemfile
11
- - gemfiles/rails_41.gemfile
12
11
  - gemfiles/rails_42.gemfile
13
12
  - gemfiles/rails_50.gemfile
14
13
  - gemfiles/rails_51.gemfile
14
+ - gemfiles/rails_52.gemfile
15
+ - gemfiles/rails_60.gemfile
15
16
 
16
17
  sudo: false
17
18
 
18
- matrix:
19
- allow_failures:
20
- - rvm: ruby-head
21
- gemfile: gemfiles/rails_40.gemfile
22
- - rvm: ruby-head
23
- gemfile: gemfiles/rails_41.gemfile
24
- - rvm: 2.4.0
25
- gemfile: gemfiles/rails_40.gemfile
26
- - rvm: 2.4.0
27
- gemfile: gemfiles/rails_41.gemfile
28
-
29
19
  script: 'bundle exec rake'
20
+
21
+ matrix:
22
+ exclude:
23
+ - rvm: 2.3.8
24
+ gemfile: gemfiles/rails_60.gemfile
25
+ - rvm: 2.4.6
26
+ gemfile: gemfiles/rails_60.gemfile
data/Appraisals CHANGED
@@ -1,19 +1,24 @@
1
- appraise 'rails-40' do
2
- gem 'activerecord', '4.0.13'
1
+ appraise 'rails-42' do
2
+ gem 'activerecord', '4.2.11.3'
3
+ gem 'sqlite3', '~> 1.3.6'
3
4
  end
4
5
 
5
- appraise 'rails-41' do
6
- gem 'activerecord', '4.1.15'
6
+ appraise 'rails-50' do
7
+ gem 'activerecord', '5.0.7.2'
8
+ gem 'sqlite3', '~> 1.3.6'
7
9
  end
8
10
 
9
- appraise 'rails-42' do
10
- gem 'activerecord', '4.2.8'
11
+ appraise 'rails-51' do
12
+ gem 'activerecord', '5.1.7'
13
+ gem 'sqlite3'
11
14
  end
12
15
 
13
- appraise 'rails-50' do
14
- gem 'activerecord', '5.0.2'
16
+ appraise 'rails-52' do
17
+ gem 'activerecord', '5.2.4.3'
18
+ gem 'sqlite3'
15
19
  end
16
20
 
17
- appraise 'rails-51' do
18
- gem 'activerecord', '5.1.4'
21
+ appraise 'rails-60' do
22
+ gem 'activerecord', '6.0.3.2'
23
+ gem 'sqlite3'
19
24
  end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017 Robin Roestenburg
1
+ Copyright (c) 2019 Robin Roestenburg
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  Deferring makes it possible to delay saving ActiveRecord associations until the
7
7
  parent object has been saved.
8
8
 
9
- Currently supporting Rails 4.x, 5.0 & 5.1 on MRI Ruby 2.3+.
9
+ Currently supporting Rails 4.2, 5.0, 5.1 & 5.2 on MRI Ruby 2.3+.
10
10
 
11
11
  It is important to note that Deferring does not touch the original `has_many`
12
12
  and `has_and_belongs_to_many` associations. You can use them, without worrying
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'deferring/version'
@@ -21,11 +20,10 @@ Gem::Specification.new do |spec|
21
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
21
  spec.require_paths = ['lib']
23
22
 
24
- spec.add_dependency 'activerecord', '> 4.0'
23
+ spec.add_dependency 'activerecord', ['>= 4.2']
25
24
 
26
25
  spec.add_development_dependency 'bundler', '~> 1.3'
27
26
  spec.add_development_dependency 'rake'
28
27
  spec.add_development_dependency 'rspec'
29
- spec.add_development_dependency 'sqlite3'
30
28
  spec.add_development_dependency 'appraisal'
31
29
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "4.2.8"
5
+ gem "activerecord", "4.2.11.3"
6
+ gem "sqlite3", "~> 1.3.6"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -1,64 +1,66 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- deferring (0.3.0)
5
- activerecord (> 4.0)
4
+ deferring (0.6.1)
5
+ activerecord (>= 4.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (4.2.8)
11
- activesupport (= 4.2.8)
10
+ activemodel (4.2.11.3)
11
+ activesupport (= 4.2.11.3)
12
12
  builder (~> 3.1)
13
- activerecord (4.2.8)
14
- activemodel (= 4.2.8)
15
- activesupport (= 4.2.8)
13
+ activerecord (4.2.11.3)
14
+ activemodel (= 4.2.11.3)
15
+ activesupport (= 4.2.11.3)
16
16
  arel (~> 6.0)
17
- activesupport (4.2.8)
17
+ activesupport (4.2.11.3)
18
18
  i18n (~> 0.7)
19
19
  minitest (~> 5.1)
20
20
  thread_safe (~> 0.3, >= 0.3.4)
21
21
  tzinfo (~> 1.1)
22
- appraisal (2.1.0)
22
+ appraisal (2.3.0)
23
23
  bundler
24
24
  rake
25
25
  thor (>= 0.14.0)
26
26
  arel (6.0.4)
27
- builder (3.2.3)
28
- diff-lcs (1.3)
29
- i18n (0.8.1)
30
- minitest (5.10.1)
31
- rake (12.0.0)
32
- rspec (3.5.0)
33
- rspec-core (~> 3.5.0)
34
- rspec-expectations (~> 3.5.0)
35
- rspec-mocks (~> 3.5.0)
36
- rspec-core (3.5.4)
37
- rspec-support (~> 3.5.0)
38
- rspec-expectations (3.5.0)
27
+ builder (3.2.4)
28
+ concurrent-ruby (1.1.6)
29
+ diff-lcs (1.4.4)
30
+ i18n (0.9.5)
31
+ concurrent-ruby (~> 1.0)
32
+ minitest (5.14.1)
33
+ rake (13.0.1)
34
+ rspec (3.9.0)
35
+ rspec-core (~> 3.9.0)
36
+ rspec-expectations (~> 3.9.0)
37
+ rspec-mocks (~> 3.9.0)
38
+ rspec-core (3.9.2)
39
+ rspec-support (~> 3.9.3)
40
+ rspec-expectations (3.9.2)
39
41
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.5.0)
41
- rspec-mocks (3.5.0)
42
+ rspec-support (~> 3.9.0)
43
+ rspec-mocks (3.9.1)
42
44
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.5.0)
44
- rspec-support (3.5.0)
45
+ rspec-support (~> 3.9.0)
46
+ rspec-support (3.9.3)
45
47
  sqlite3 (1.3.13)
46
- thor (0.19.4)
48
+ thor (1.0.1)
47
49
  thread_safe (0.3.6)
48
- tzinfo (1.2.2)
50
+ tzinfo (1.2.7)
49
51
  thread_safe (~> 0.1)
50
52
 
51
53
  PLATFORMS
52
54
  ruby
53
55
 
54
56
  DEPENDENCIES
55
- activerecord (= 4.2.8)
57
+ activerecord (= 4.2.11.3)
56
58
  appraisal
57
59
  bundler (~> 1.3)
58
60
  deferring!
59
61
  rake
60
62
  rspec
61
- sqlite3
63
+ sqlite3 (~> 1.3.6)
62
64
 
63
65
  BUNDLED WITH
64
- 1.13.0
66
+ 1.17.3
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "5.0.2"
5
+ gem "activerecord", "5.0.7.2"
6
+ gem "sqlite3", "~> 1.3.6"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -1,63 +1,64 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- deferring (0.3.0)
5
- activerecord (> 4.0)
4
+ deferring (0.6.1)
5
+ activerecord (>= 4.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (5.0.2)
11
- activesupport (= 5.0.2)
12
- activerecord (5.0.2)
13
- activemodel (= 5.0.2)
14
- activesupport (= 5.0.2)
10
+ activemodel (5.0.7.2)
11
+ activesupport (= 5.0.7.2)
12
+ activerecord (5.0.7.2)
13
+ activemodel (= 5.0.7.2)
14
+ activesupport (= 5.0.7.2)
15
15
  arel (~> 7.0)
16
- activesupport (5.0.2)
16
+ activesupport (5.0.7.2)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (~> 0.7)
18
+ i18n (>= 0.7, < 2)
19
19
  minitest (~> 5.1)
20
20
  tzinfo (~> 1.1)
21
- appraisal (2.1.0)
21
+ appraisal (2.3.0)
22
22
  bundler
23
23
  rake
24
24
  thor (>= 0.14.0)
25
25
  arel (7.1.4)
26
- concurrent-ruby (1.0.5)
27
- diff-lcs (1.3)
28
- i18n (0.8.1)
29
- minitest (5.10.1)
30
- rake (12.0.0)
31
- rspec (3.5.0)
32
- rspec-core (~> 3.5.0)
33
- rspec-expectations (~> 3.5.0)
34
- rspec-mocks (~> 3.5.0)
35
- rspec-core (3.5.4)
36
- rspec-support (~> 3.5.0)
37
- rspec-expectations (3.5.0)
26
+ concurrent-ruby (1.1.6)
27
+ diff-lcs (1.4.4)
28
+ i18n (1.8.3)
29
+ concurrent-ruby (~> 1.0)
30
+ minitest (5.14.1)
31
+ rake (13.0.1)
32
+ rspec (3.9.0)
33
+ rspec-core (~> 3.9.0)
34
+ rspec-expectations (~> 3.9.0)
35
+ rspec-mocks (~> 3.9.0)
36
+ rspec-core (3.9.2)
37
+ rspec-support (~> 3.9.3)
38
+ rspec-expectations (3.9.2)
38
39
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.5.0)
40
- rspec-mocks (3.5.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-mocks (3.9.1)
41
42
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.5.0)
43
- rspec-support (3.5.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-support (3.9.3)
44
45
  sqlite3 (1.3.13)
45
- thor (0.19.4)
46
+ thor (1.0.1)
46
47
  thread_safe (0.3.6)
47
- tzinfo (1.2.2)
48
+ tzinfo (1.2.7)
48
49
  thread_safe (~> 0.1)
49
50
 
50
51
  PLATFORMS
51
52
  ruby
52
53
 
53
54
  DEPENDENCIES
54
- activerecord (= 5.0.2)
55
+ activerecord (= 5.0.7.2)
55
56
  appraisal
56
57
  bundler (~> 1.3)
57
58
  deferring!
58
59
  rake
59
60
  rspec
60
- sqlite3
61
+ sqlite3 (~> 1.3.6)
61
62
 
62
63
  BUNDLED WITH
63
- 1.13.0
64
+ 1.17.3
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "5.1.4"
5
+ gem "activerecord", "5.1.7"
6
+ gem "sqlite3"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -1,58 +1,58 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- deferring (0.3.0)
5
- activerecord (> 4.0)
4
+ deferring (0.6.1)
5
+ activerecord (>= 4.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (5.1.4)
11
- activesupport (= 5.1.4)
12
- activerecord (5.1.4)
13
- activemodel (= 5.1.4)
14
- activesupport (= 5.1.4)
10
+ activemodel (5.1.7)
11
+ activesupport (= 5.1.7)
12
+ activerecord (5.1.7)
13
+ activemodel (= 5.1.7)
14
+ activesupport (= 5.1.7)
15
15
  arel (~> 8.0)
16
- activesupport (5.1.4)
16
+ activesupport (5.1.7)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (~> 0.7)
18
+ i18n (>= 0.7, < 2)
19
19
  minitest (~> 5.1)
20
20
  tzinfo (~> 1.1)
21
- appraisal (2.2.0)
21
+ appraisal (2.3.0)
22
22
  bundler
23
23
  rake
24
24
  thor (>= 0.14.0)
25
25
  arel (8.0.0)
26
- concurrent-ruby (1.0.5)
27
- diff-lcs (1.3)
28
- i18n (0.9.1)
26
+ concurrent-ruby (1.1.6)
27
+ diff-lcs (1.4.4)
28
+ i18n (1.8.3)
29
29
  concurrent-ruby (~> 1.0)
30
- minitest (5.10.3)
31
- rake (12.3.0)
32
- rspec (3.7.0)
33
- rspec-core (~> 3.7.0)
34
- rspec-expectations (~> 3.7.0)
35
- rspec-mocks (~> 3.7.0)
36
- rspec-core (3.7.0)
37
- rspec-support (~> 3.7.0)
38
- rspec-expectations (3.7.0)
30
+ minitest (5.14.1)
31
+ rake (13.0.1)
32
+ rspec (3.9.0)
33
+ rspec-core (~> 3.9.0)
34
+ rspec-expectations (~> 3.9.0)
35
+ rspec-mocks (~> 3.9.0)
36
+ rspec-core (3.9.2)
37
+ rspec-support (~> 3.9.3)
38
+ rspec-expectations (3.9.2)
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.7.0)
41
- rspec-mocks (3.7.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-mocks (3.9.1)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.7.0)
44
- rspec-support (3.7.0)
45
- sqlite3 (1.3.13)
46
- thor (0.20.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-support (3.9.3)
45
+ sqlite3 (1.4.2)
46
+ thor (1.0.1)
47
47
  thread_safe (0.3.6)
48
- tzinfo (1.2.4)
48
+ tzinfo (1.2.7)
49
49
  thread_safe (~> 0.1)
50
50
 
51
51
  PLATFORMS
52
52
  ruby
53
53
 
54
54
  DEPENDENCIES
55
- activerecord (= 5.1.4)
55
+ activerecord (= 5.1.7)
56
56
  appraisal
57
57
  bundler (~> 1.3)
58
58
  deferring!
@@ -61,4 +61,4 @@ DEPENDENCIES
61
61
  sqlite3
62
62
 
63
63
  BUNDLED WITH
64
- 1.13.0
64
+ 1.17.3
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "4.0.13"
5
+ gem "activerecord", "5.2.4.3"
6
+ gem "sqlite3"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ deferring (0.6.1)
5
+ activerecord (>= 4.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (5.2.4.3)
11
+ activesupport (= 5.2.4.3)
12
+ activerecord (5.2.4.3)
13
+ activemodel (= 5.2.4.3)
14
+ activesupport (= 5.2.4.3)
15
+ arel (>= 9.0)
16
+ activesupport (5.2.4.3)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 0.7, < 2)
19
+ minitest (~> 5.1)
20
+ tzinfo (~> 1.1)
21
+ appraisal (2.3.0)
22
+ bundler
23
+ rake
24
+ thor (>= 0.14.0)
25
+ arel (9.0.0)
26
+ concurrent-ruby (1.1.6)
27
+ diff-lcs (1.4.4)
28
+ i18n (1.8.3)
29
+ concurrent-ruby (~> 1.0)
30
+ minitest (5.14.1)
31
+ rake (13.0.1)
32
+ rspec (3.9.0)
33
+ rspec-core (~> 3.9.0)
34
+ rspec-expectations (~> 3.9.0)
35
+ rspec-mocks (~> 3.9.0)
36
+ rspec-core (3.9.2)
37
+ rspec-support (~> 3.9.3)
38
+ rspec-expectations (3.9.2)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.9.0)
41
+ rspec-mocks (3.9.1)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-support (3.9.3)
45
+ sqlite3 (1.4.2)
46
+ thor (1.0.1)
47
+ thread_safe (0.3.6)
48
+ tzinfo (1.2.7)
49
+ thread_safe (~> 0.1)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ activerecord (= 5.2.4.3)
56
+ appraisal
57
+ bundler (~> 1.3)
58
+ deferring!
59
+ rake
60
+ rspec
61
+ sqlite3
62
+
63
+ BUNDLED WITH
64
+ 1.17.3
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "4.1.15"
5
+ gem "activerecord", "6.0.3.2"
6
+ gem "sqlite3"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ deferring (0.6.1)
5
+ activerecord (>= 4.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (6.0.3.2)
11
+ activesupport (= 6.0.3.2)
12
+ activerecord (6.0.3.2)
13
+ activemodel (= 6.0.3.2)
14
+ activesupport (= 6.0.3.2)
15
+ activesupport (6.0.3.2)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 0.7, < 2)
18
+ minitest (~> 5.1)
19
+ tzinfo (~> 1.1)
20
+ zeitwerk (~> 2.2, >= 2.2.2)
21
+ appraisal (2.3.0)
22
+ bundler
23
+ rake
24
+ thor (>= 0.14.0)
25
+ concurrent-ruby (1.1.6)
26
+ diff-lcs (1.4.4)
27
+ i18n (1.8.3)
28
+ concurrent-ruby (~> 1.0)
29
+ minitest (5.14.1)
30
+ rake (13.0.1)
31
+ rspec (3.9.0)
32
+ rspec-core (~> 3.9.0)
33
+ rspec-expectations (~> 3.9.0)
34
+ rspec-mocks (~> 3.9.0)
35
+ rspec-core (3.9.2)
36
+ rspec-support (~> 3.9.3)
37
+ rspec-expectations (3.9.2)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.9.0)
40
+ rspec-mocks (3.9.1)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.9.0)
43
+ rspec-support (3.9.3)
44
+ sqlite3 (1.4.2)
45
+ thor (1.0.1)
46
+ thread_safe (0.3.6)
47
+ tzinfo (1.2.7)
48
+ thread_safe (~> 0.1)
49
+ zeitwerk (2.3.1)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ activerecord (= 6.0.3.2)
56
+ appraisal
57
+ bundler (~> 1.3)
58
+ deferring!
59
+ rake
60
+ rspec
61
+ sqlite3
62
+
63
+ BUNDLED WITH
64
+ 1.17.3
@@ -261,7 +261,12 @@ module Deferring
261
261
  # association and store the result.
262
262
  deferred_association = send(deferred_association_name)
263
263
  if deferred_association.send(:objects_loaded?)
264
- send(:"original_#{association_name}=", deferred_association.objects)
264
+ send(:"original_#{association_name}").delete(deferred_association.unlinks)
265
+ unless send(:"original_#{association_name}").push(deferred_association.links)
266
+ raise ActiveRecord::RecordNotSaved,
267
+ "Failed to replace #{association_name} because one or more of " \
268
+ "the new records could not be saved."
269
+ end
265
270
  end
266
271
 
267
272
  # Store the new value of the association into our delegated association.
@@ -47,6 +47,7 @@ module Deferring
47
47
  # association.
48
48
  delegate :[]=, :[], :clear, :select!, :reject!, :flatten, :flatten!, :sort!,
49
49
  :keep_if, :delete_if, :sort_by!, :empty?, :size, :length,
50
+ :each_index,
50
51
  to: :objects
51
52
 
52
53
  # Delegates Ruby's Enumerable#find method to the original association.
@@ -64,9 +65,9 @@ module Deferring
64
65
  #
65
66
  # The delegation has to be explicit in this case, because the inclusion of
66
67
  # Enumerable also defines the select-method on DeferredAssociation.
67
- def select(value = Proc.new)
68
+ def select(value = nil, &block)
68
69
  if block_given?
69
- objects.select { |*block_args| value.call(*block_args) }
70
+ objects.select { |*block_args| block.call(*block_args) }
70
71
  else
71
72
  original_association.select(value)
72
73
  end
@@ -131,7 +132,7 @@ module Deferring
131
132
  def destroy(*records)
132
133
  records.flatten.compact.uniq.each do |record|
133
134
  record = record.to_i if record.is_a? String
134
- record = objects.detect { |o| o.id == record } if record.is_a? Fixnum
135
+ record = objects.detect { |o| o.id == record } if record.is_a? Integer
135
136
 
136
137
  run_deferring_callbacks(:unlink, record) {
137
138
  objects.delete(record)
@@ -1,3 +1,3 @@
1
1
  module Deferring
2
- VERSION = '0.4.0'
2
+ VERSION = '0.6.2'
3
3
  end
@@ -377,6 +377,19 @@ RSpec.describe 'deferred has_and_belongs_to_many associations' do
377
377
  end
378
378
  end
379
379
 
380
+ describe 'supports methods from Ruby Array' do
381
+ describe '#each_index' do
382
+ it 'returns the index of each element in the association' do
383
+ bob.teams << dba << support
384
+ bob.save!
385
+
386
+ result = []
387
+ bob.teams.each_index { |i| result << i }
388
+ expect(result).to eq([0, 1])
389
+ end
390
+ end
391
+ end
392
+
380
393
  describe 'enumerable methods that conflict with ActiveRecord' do
381
394
  describe '#select' do
382
395
  before do
@@ -9,6 +9,7 @@ RSpec.describe 'deferred accepts_nested_attributes' do
9
9
  Team.create!(name: 'Database Administration')
10
10
  Team.create!(name: 'End-User Support')
11
11
  Team.create!(name: 'Operations')
12
+
12
13
  end
13
14
 
14
15
  let(:bob) { Person.where(name: 'Bob').first }
@@ -47,4 +48,21 @@ RSpec.describe 'deferred accepts_nested_attributes' do
47
48
  expect(p.team_ids.sort).to eq([1])
48
49
  end
49
50
 
51
+ it '' do
52
+ issue = Issue.create!(subject: 'Foo', person: bob)
53
+
54
+ p = Person.where(name: 'Alice').take
55
+ p.attributes = {
56
+ issues_attributes: [
57
+ { id: issue.id },
58
+ ]
59
+ }
60
+ p.save!
61
+
62
+ p.reload
63
+ expect(p.issues.size).to eq(1)
64
+
65
+ bob.reload
66
+ expect(bob.issues.size).to eq(0)
67
+ end
50
68
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deferring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Roestenburg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2020-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: sqlite3
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: appraisal
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -111,16 +97,16 @@ files:
111
97
  - README.md
112
98
  - Rakefile
113
99
  - deferring.gemspec
114
- - gemfiles/rails_40.gemfile
115
- - gemfiles/rails_40.gemfile.lock
116
- - gemfiles/rails_41.gemfile
117
- - gemfiles/rails_41.gemfile.lock
118
100
  - gemfiles/rails_42.gemfile
119
101
  - gemfiles/rails_42.gemfile.lock
120
102
  - gemfiles/rails_50.gemfile
121
103
  - gemfiles/rails_50.gemfile.lock
122
104
  - gemfiles/rails_51.gemfile
123
105
  - gemfiles/rails_51.gemfile.lock
106
+ - gemfiles/rails_52.gemfile
107
+ - gemfiles/rails_52.gemfile.lock
108
+ - gemfiles/rails_60.gemfile
109
+ - gemfiles/rails_60.gemfile.lock
124
110
  - lib/deferring.rb
125
111
  - lib/deferring/deferred_association.rb
126
112
  - lib/deferring/deferred_callback_listener.rb
@@ -155,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
141
  version: '0'
156
142
  requirements: []
157
143
  rubyforge_project:
158
- rubygems_version: 2.5.1
144
+ rubygems_version: 2.7.6.2
159
145
  signing_key:
160
146
  specification_version: 4
161
147
  summary: Defer saving ActiveRecord associations until parent is saved
@@ -170,4 +156,3 @@ test_files:
170
156
  - spec/support/models/non_validated_issue.rb
171
157
  - spec/support/models/person.rb
172
158
  - spec/support/models/team.rb
173
- has_rdoc:
@@ -1,67 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- deferring (0.3.0)
5
- activerecord (> 4.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (4.0.13)
11
- activesupport (= 4.0.13)
12
- builder (~> 3.1.0)
13
- activerecord (4.0.13)
14
- activemodel (= 4.0.13)
15
- activerecord-deprecated_finders (~> 1.0.2)
16
- activesupport (= 4.0.13)
17
- arel (~> 4.0.0)
18
- activerecord-deprecated_finders (1.0.4)
19
- activesupport (4.0.13)
20
- i18n (~> 0.6, >= 0.6.9)
21
- minitest (~> 4.2)
22
- multi_json (~> 1.3)
23
- thread_safe (~> 0.1)
24
- tzinfo (~> 0.3.37)
25
- appraisal (2.1.0)
26
- bundler
27
- rake
28
- thor (>= 0.14.0)
29
- arel (4.0.2)
30
- builder (3.1.4)
31
- diff-lcs (1.3)
32
- i18n (0.8.1)
33
- minitest (4.7.5)
34
- multi_json (1.12.1)
35
- rake (12.0.0)
36
- rspec (3.5.0)
37
- rspec-core (~> 3.5.0)
38
- rspec-expectations (~> 3.5.0)
39
- rspec-mocks (~> 3.5.0)
40
- rspec-core (3.5.4)
41
- rspec-support (~> 3.5.0)
42
- rspec-expectations (3.5.0)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.5.0)
45
- rspec-mocks (3.5.0)
46
- diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.5.0)
48
- rspec-support (3.5.0)
49
- sqlite3 (1.3.13)
50
- thor (0.19.4)
51
- thread_safe (0.3.6)
52
- tzinfo (0.3.52)
53
-
54
- PLATFORMS
55
- ruby
56
-
57
- DEPENDENCIES
58
- activerecord (= 4.0.13)
59
- appraisal
60
- bundler (~> 1.3)
61
- deferring!
62
- rake
63
- rspec
64
- sqlite3
65
-
66
- BUNDLED WITH
67
- 1.13.0
@@ -1,66 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- deferring (0.3.0)
5
- activerecord (> 4.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (4.1.15)
11
- activesupport (= 4.1.15)
12
- builder (~> 3.1)
13
- activerecord (4.1.15)
14
- activemodel (= 4.1.15)
15
- activesupport (= 4.1.15)
16
- arel (~> 5.0.0)
17
- activesupport (4.1.15)
18
- i18n (~> 0.6, >= 0.6.9)
19
- json (~> 1.7, >= 1.7.7)
20
- minitest (~> 5.1)
21
- thread_safe (~> 0.1)
22
- tzinfo (~> 1.1)
23
- appraisal (2.1.0)
24
- bundler
25
- rake
26
- thor (>= 0.14.0)
27
- arel (5.0.1.20140414130214)
28
- builder (3.2.3)
29
- diff-lcs (1.3)
30
- i18n (0.8.1)
31
- json (1.8.6)
32
- minitest (5.10.1)
33
- rake (12.0.0)
34
- rspec (3.5.0)
35
- rspec-core (~> 3.5.0)
36
- rspec-expectations (~> 3.5.0)
37
- rspec-mocks (~> 3.5.0)
38
- rspec-core (3.5.4)
39
- rspec-support (~> 3.5.0)
40
- rspec-expectations (3.5.0)
41
- diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.5.0)
43
- rspec-mocks (3.5.0)
44
- diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.5.0)
46
- rspec-support (3.5.0)
47
- sqlite3 (1.3.13)
48
- thor (0.19.4)
49
- thread_safe (0.3.6)
50
- tzinfo (1.2.2)
51
- thread_safe (~> 0.1)
52
-
53
- PLATFORMS
54
- ruby
55
-
56
- DEPENDENCIES
57
- activerecord (= 4.1.15)
58
- appraisal
59
- bundler (~> 1.3)
60
- deferring!
61
- rake
62
- rspec
63
- sqlite3
64
-
65
- BUNDLED WITH
66
- 1.13.0