protected_attributes_continued 1.8.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a53af38e43c5d8fee4bf8cb3f199422844d27b7104ac13e3c31b7bdc7af192a
4
- data.tar.gz: 318cd88bd28f923e8ba90c5dc9e8e837cab4427501adde30b1797ab24234c96d
3
+ metadata.gz: 5e881236bacf8378d98f06eb98269417a5082383de65360f522e524062fbcdfb
4
+ data.tar.gz: 45f598ce1954ed9542934e676af3ac8f53e6b5c6dea2c35e87b3100721d2522a
5
5
  SHA512:
6
- metadata.gz: d9dcf4759ad7112b4b8d3191c28458ae8aa36503ae945fc481ca798e1c3e4f86bc815fc63da6d0dee616f88b70563c30e8d5a19da6ac26c05eecdf99172a2540
7
- data.tar.gz: d3ffa567d9ce6896bb1ddd398a796eef5bedbf090dc08e8b00db56cdc4b132cc9776ed42b48a637382b1027dff2f40a419a8f7f4e965132ac996b21b00043e90
6
+ metadata.gz: 30fb108c2db47feeb17c7787dc1427a44e93b7ac47450d79f20d59a3bf814d3f8314eb42ee71a76bd3e1f54dbec508d56e917ab0f57d5a6c7c7e5a68a4ac2d8d
7
+ data.tar.gz: '0486645654d15f177a2ba9abd27069c598b9d08884a7beb4db9d7813ce79604265d0eab9263f937aa0957c963cbd66dc435d4628993381793789068d04d0573b'
@@ -5,29 +5,41 @@ module ActiveRecord
5
5
  undef :create!
6
6
 
7
7
  def build(attributes = nil, options = {}, &block)
8
- if ActiveRecord::VERSION::STRING.to_f < 5.2
9
- scoping { @association.build(attributes, options, &block) }
10
- else
11
- @association.build(attributes, options, &block)
12
- end
8
+ block = protected_attributes_scope_block('new', block)
9
+ scoping { @association.build(attributes, options, &block) }
13
10
  end
14
11
  alias new build
15
12
 
16
13
  def create(attributes = nil, options = {}, &block)
17
- if ActiveRecord::VERSION::STRING.to_f < 5.2
18
- scoping { @association.create(attributes, options, &block) }
19
- else
20
- @association.create(attributes, options, &block)
21
- end
14
+ block = protected_attributes_scope_block('create', block)
15
+ scoping { @association.create(attributes, options, &block) }
22
16
  end
23
17
 
24
18
  def create!(attributes = nil, options = {}, &block)
25
- if ActiveRecord::VERSION::STRING.to_f < 5.2
26
- scoping { @association.create!(attributes, options, &block) }
27
- else
28
- @association.create!(attributes, options, &block)
29
- end
19
+ block = protected_attributes_scope_block('create!', block)
20
+ scoping { @association.create!(attributes, options, &block) }
30
21
  end
31
22
 
23
+ private
24
+
25
+ if ActiveRecord.gem_version < Gem::Version.new('6.0')
26
+
27
+ def protected_attributes_scope_block(_label, block)
28
+ block
29
+ end
30
+
31
+ elsif ActiveRecord.gem_version < Gem::Version.new('6.1')
32
+
33
+ def protected_attributes_scope_block(label, block)
34
+ _deprecated_scope_block(label, &block)
35
+ end
36
+
37
+ else
38
+
39
+ def protected_attributes_scope_block(_label, block)
40
+ current_scope_restoring_block(&block)
41
+ end
42
+
43
+ end
32
44
  end
33
45
  end
@@ -1,3 +1,3 @@
1
1
  module ProtectedAttributes
2
- VERSION = "1.8.0".freeze
2
+ VERSION = "1.8.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protected_attributes_continued
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-06 00:00:00.000000000 Z
11
+ date: 2021-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel