From af99f45b58b5264229f588df18a28dddcca2d678 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 8 Sep 2019 09:44:47 +0900 Subject: [PATCH] Revert "Class#new also separates keyword arguments and optional hash" This reverts commit 72c1aa21c1f88dbe4c60413fb937df41987068e5. This causes CI fails on Ruby < 2.7 --- activemodel/lib/active_model/errors.rb | 6 ++++-- .../connection_adapters/abstract/schema_definitions.rb | 2 +- .../lib/active_record/connection_adapters/deduplicable.rb | 2 +- .../connection_adapters/postgresql/schema_definitions.rb | 2 +- activerecord/lib/active_record/relation/delegation.rb | 4 ++-- .../lib/active_support/deprecation/proxy_wrappers.rb | 2 +- activesupport/lib/active_support/encrypted_file.rb | 2 +- activesupport/lib/active_support/messages/rotator.rb | 4 ++-- activesupport/test/message_encryptor_test.rb | 4 ++-- activesupport/test/message_verifier_test.rb | 2 +- 10 files changed, 16 insertions(+), 14 deletions(-) diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index f5944e7cf6..ecbe445e4a 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -371,8 +371,10 @@ module ActiveModel # person.errors.details # # => {:base=>[{error: :name_or_email_blank}]} def add(attribute, type = :invalid, **options) - attribute, type, options = normalize_arguments(attribute, type, **options) - error = Error.new(@base, attribute, type, **options) + error = Error.new( + @base, + *normalize_arguments(attribute, type, **options) + ) if exception = options[:strict] exception = ActiveModel::StrictValidationFailed if exception == true diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 289fcb016c..b6f064ab6c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -422,7 +422,7 @@ module ActiveRecord # See {connection.add_reference}[rdoc-ref:SchemaStatements#add_reference] for details of the options you can use. def references(*args, **options) args.each do |ref_name| - ReferenceDefinition.new(ref_name, **options).add_to(self) + ReferenceDefinition.new(ref_name, options).add_to(self) end end alias :belongs_to :references diff --git a/activerecord/lib/active_record/connection_adapters/deduplicable.rb b/activerecord/lib/active_record/connection_adapters/deduplicable.rb index 030fd171be..fb2fd60bbc 100644 --- a/activerecord/lib/active_record/connection_adapters/deduplicable.rb +++ b/activerecord/lib/active_record/connection_adapters/deduplicable.rb @@ -10,7 +10,7 @@ module ActiveRecord @registry ||= {} end - def new(*, **) + def new(*) super.deduplicate end end diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb index 754cbbdd6b..3bb7c52899 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb @@ -186,7 +186,7 @@ module ActiveRecord attr_reader :unlogged - def initialize(*, **) + def initialize(*) super @unlogged = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables end diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb index fcb5092280..2f61c05eca 100644 --- a/activerecord/lib/active_record/relation/delegation.rb +++ b/activerecord/lib/active_record/relation/delegation.rb @@ -110,8 +110,8 @@ module ActiveRecord end module ClassMethods # :nodoc: - def create(klass, *args, **options) - relation_class_for(klass).new(klass, *args, **options) + def create(klass, *args) + relation_class_for(klass).new(klass, *args) end private diff --git a/activesupport/lib/active_support/deprecation/proxy_wrappers.rb b/activesupport/lib/active_support/deprecation/proxy_wrappers.rb index 2d2c54c5ef..d7d3c30b97 100644 --- a/activesupport/lib/active_support/deprecation/proxy_wrappers.rb +++ b/activesupport/lib/active_support/deprecation/proxy_wrappers.rb @@ -121,7 +121,7 @@ module ActiveSupport # (Backtrace information…) # ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"] class DeprecatedConstantProxy < Module - def self.new(*args, **options, &block) + def self.new(*args, &block) object = args.first return object unless object diff --git a/activesupport/lib/active_support/encrypted_file.rb b/activesupport/lib/active_support/encrypted_file.rb index 544dacb7e5..2b7db568a5 100644 --- a/activesupport/lib/active_support/encrypted_file.rb +++ b/activesupport/lib/active_support/encrypted_file.rb @@ -94,7 +94,7 @@ module ActiveSupport end def handle_missing_key - raise MissingKeyError.new(key_path: key_path, env_key: env_key) if raise_if_missing_key + raise MissingKeyError, key_path: key_path, env_key: env_key if raise_if_missing_key end end end diff --git a/activesupport/lib/active_support/messages/rotator.rb b/activesupport/lib/active_support/messages/rotator.rb index 920000a136..b0dcf8a105 100644 --- a/activesupport/lib/active_support/messages/rotator.rb +++ b/activesupport/lib/active_support/messages/rotator.rb @@ -26,7 +26,7 @@ module ActiveSupport private def build_rotation(secret = @secret, sign_secret = @sign_secret, options) - self.class.new(secret, sign_secret, **options) + self.class.new(secret, sign_secret, options) end end @@ -39,7 +39,7 @@ module ActiveSupport private def build_rotation(secret = @secret, options) - self.class.new(secret, **options) + self.class.new(secret, options) end end diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb index 150c10f750..9f38eb8f74 100644 --- a/activesupport/test/message_encryptor_test.rb +++ b/activesupport/test/message_encryptor_test.rb @@ -244,7 +244,7 @@ class MessageEncryptorMetadataTest < ActiveSupport::TestCase setup do @secret = SecureRandom.random_bytes(32) - @encryptor = ActiveSupport::MessageEncryptor.new(@secret, **encryptor_options) + @encryptor = ActiveSupport::MessageEncryptor.new(@secret, encryptor_options) end private @@ -256,7 +256,7 @@ class MessageEncryptorMetadataTest < ActiveSupport::TestCase @encryptor.decrypt_and_verify(data, **options) end - def encryptor_options; {} end + def encryptor_options; end end class MessageEncryptorMetadataMarshalTest < MessageEncryptorMetadataTest diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb index 84bec9c1a0..4e8461722e 100644 --- a/activesupport/test/message_verifier_test.rb +++ b/activesupport/test/message_verifier_test.rb @@ -142,7 +142,7 @@ class MessageVerifierMetadataTest < ActiveSupport::TestCase include SharedMessageMetadataTests setup do - @verifier = ActiveSupport::MessageVerifier.new("Hey, I'm a secret!", **verifier_options) + @verifier = ActiveSupport::MessageVerifier.new("Hey, I'm a secret!", verifier_options) end def test_verify_raises_when_purpose_differs