accepts_nested_attributes_for_public_id 1.0.0 → 1.0.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: 0c66a87c5663498998b2263ec28d9f1f1bafde4101e93190b1d3e336c2c12605
4
- data.tar.gz: bed9e7a6048e6d2f9761acc39156f2bc359e2ba5bac144505061d592792faaa5
3
+ metadata.gz: f30d194a7b2fb866d90ad1f136123a1778941ff1fd48105f1a4068e667110884
4
+ data.tar.gz: f60c0932253ce1879bcb0d187866edf6b530944ffa2221e471857ee62fd820a4
5
5
  SHA512:
6
- metadata.gz: 45592a78a5438ef544dd687dbf52624efaf8e194d31a083736ace28dba20eb254670bb584e71d72bc2c141a078cbf7127d5909c8feb19f88d03feb85147b5868
7
- data.tar.gz: a14e83ac5d39575dde70a0c0ec4ab5b0833ca681efc8b64a198d2417528cd03903c7f2818996f75cc56d1531c5011d00e26705600d63ecca1f092956a0512612
6
+ metadata.gz: b3e83a88567e8550394ced1c5220cd876f8f14172a282ba2803a5474af62e3c95bb0e54bcc39a6145fb0c588247bb8a36c1d10911c97e9b9097e5a89cbf8fef5
7
+ data.tar.gz: b47a373d9ecbb65f78f181afb61c7ee5ee3bc7c318fe71589aa5cc090861dc86d064e691ced318c13fee30f886304af410a74e72738557fecfca39d5749b788a
data/CHANGELOG.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
3
  - **Unreleased**
4
- * [View Diff](https://github.com/westonganger/accepts_nested_attributes_for_public_id/compare/v1.0.0...master)
4
+ * [View Diff](https://github.com/westonganger/accepts_nested_attributes_for_public_id/compare/v1.0.1...master)
5
5
  * Nothing yet
6
6
 
7
+ - **v1.0.1**
8
+ * [View Diff](https://github.com/westonganger/accepts_nested_attributes_for_public_id/compare/v1.0.0...v1.0.1)
9
+ * Add a couple allowed method contract violations for Rails 6.1 and below
10
+ * Resolve filter_map usage for compatibility with Ruby 2.6 and below
11
+
7
12
  - **v1.0.0**
8
13
  * Initial gem release
@@ -1,7 +1,13 @@
1
1
  module AcceptsNestedAttributesForPublicId
2
+ ALLOWED_VIOLATIONS = [
3
+ ->(method) { Rails::VERSION::MAJOR < 7 && method.name == :assign_nested_attributes_for_collection_association }, ### small change from `map.compact` to `filter_map`
4
+ ->(method) { Rails::VERSION::MAJOR < 7 && method.name == :fields_for_with_nested_attributes }, ### small syntax change
5
+ ]
6
+
2
7
  def verify_method_contract!(method, contract)
3
8
  if method.source.strip.gsub(/^\s*/, "") != contract.strip.gsub(/^\s*/, "")
4
- raise RuntimeError.new("Method definition contract violated for '#{self.class.name}##{method.name}', cannot apply patch for accepts_nested_attribute_for_public_id")
9
+ return if ALLOWED_VIOLATIONS.any?{|x| x.call(method) }
10
+ raise RuntimeError.new("Method definition contract violated for '#{method.owner}##{method.name}', cannot apply patch for accepts_nested_attributes_for_public_id")
5
11
  end
6
12
  end
7
13
  module_function :verify_method_contract!
@@ -188,7 +188,7 @@ ActiveSupport.on_load(:active_record) do
188
188
  existing_records = if association.loaded?
189
189
  association.target
190
190
  else
191
- attribute_ids = attributes_collection.filter_map { |a| a["id"] || a[:id] }
191
+ attribute_ids = attributes_collection.map { |a| a["id"] || a[:id] }.compact
192
192
  ### ORIGINAL
193
193
  # attribute_ids.empty? ? [] : association.scope.where(association.klass.primary_key => attribute_ids)
194
194
  ### NEW
@@ -1,3 +1,3 @@
1
1
  module AcceptsNestedAttributesForPublicId
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: accepts_nested_attributes_for_public_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger