protected_attributes_continued 1.8.1 → 1.8.2

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: 5e881236bacf8378d98f06eb98269417a5082383de65360f522e524062fbcdfb
4
- data.tar.gz: 45f598ce1954ed9542934e676af3ac8f53e6b5c6dea2c35e87b3100721d2522a
3
+ metadata.gz: 86d47e2aa9219271973c37cb944a3b5722c1d9667718eee090fbf3fe4df2c1de
4
+ data.tar.gz: c548ba06b3f2f884b2e6ec4e7ef8252755af23c837c2394d9212a9858e8334e9
5
5
  SHA512:
6
- metadata.gz: 30fb108c2db47feeb17c7787dc1427a44e93b7ac47450d79f20d59a3bf814d3f8314eb42ee71a76bd3e1f54dbec508d56e917ab0f57d5a6c7c7e5a68a4ac2d8d
7
- data.tar.gz: '0486645654d15f177a2ba9abd27069c598b9d08884a7beb4db9d7813ce79604265d0eab9263f937aa0957c963cbd66dc435d4628993381793789068d04d0573b'
6
+ metadata.gz: 74a4ee291ffbd2be19f45ddbee0bdd1b2b489bee22a4298399f814e140094551846bbf50cd4ac481c0ded209f8a80fa0cffb8d1c75c9d73c471d2eae00a133f2
7
+ data.tar.gz: c86f600a36c43204c193fd10558f7808857f578c4edbe3cf7af6425be7c7ba7ccc41c65c113305404f8dc18a90576550e66e605cc32185865f0642bd56053d8c
@@ -55,6 +55,18 @@ module ActiveRecord
55
55
  end
56
56
  end
57
57
  private :create_record
58
+
59
+ if ActiveRecord.version >= Gem::Version.new("6.0.4") && ActiveRecord.version < Gem::Version.new("6.1")
60
+ undef :build_record
61
+
62
+ def build_record(attributes, options)
63
+ previous = klass.current_scope(true) if block_given?
64
+ super
65
+ ensure
66
+ klass.current_scope = previous if previous
67
+ end
68
+ private :build_record
69
+ end
58
70
  end
59
71
 
60
72
  class CollectionProxy
@@ -92,7 +104,23 @@ module ActiveRecord
92
104
  end
93
105
 
94
106
  class HasManyThroughAssociation
95
- if ActiveRecord.version >= Gem::Version.new('5.2.3')
107
+ if ActiveRecord.version >= Gem::Version.new('6.1')
108
+ undef :build_through_record
109
+ def build_through_record(record)
110
+ @through_records[record] ||= begin
111
+ ensure_mutable
112
+
113
+ attributes = through_scope_attributes
114
+ attributes[source_reflection.name] = record
115
+ attributes[source_reflection.foreign_type] = options[:source_type] if options[:source_type]
116
+
117
+ # Pass in `without_protection: true` here because `options_for_through_record`
118
+ # was removed in https://github.com/rails/rails/pull/35799
119
+ through_association.build(attributes, without_protection: true)
120
+ end
121
+ end
122
+ private :build_through_record
123
+ elsif ActiveRecord.version >= Gem::Version.new('5.2.3')
96
124
  undef :build_through_record
97
125
  def build_through_record(record)
98
126
  @through_records[record.object_id] ||= begin
@@ -1,3 +1,3 @@
1
1
  module ProtectedAttributes
2
- VERSION = "1.8.1".freeze
2
+ VERSION = "1.8.2".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.1
4
+ version: 1.8.2
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-24 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
- rubygems_version: 3.1.2
144
+ rubygems_version: 3.1.4
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Protect attributes from mass assignment in Active Record models