-
-
Save mame/18cd2dfc7d965d0bad1216f2fdd008ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb | |
index f71c7336fe..6edbe2ff65 100644 | |
--- a/actionmailer/lib/action_mailer/base.rb | |
+++ b/actionmailer/lib/action_mailer/base.rb | |
@@ -612,7 +612,7 @@ def set_payload_for_mail(payload, mail) | |
payload[:perform_deliveries] = mail.perform_deliveries | |
end | |
- def method_missing(method_name, *args) | |
+ ruby2_keywords def method_missing(method_name, *args) | |
if action_methods.include?(method_name.to_s) | |
MessageDelivery.new(self, method_name, *args) | |
else | |
@@ -633,7 +633,7 @@ def initialize | |
@_message = Mail.new | |
end | |
- def process(method_name, *args) #:nodoc: | |
+ ruby2_keywords def process(method_name, *args) #:nodoc: | |
payload = { | |
mailer: self.class.name, | |
action: method_name, | |
@@ -654,7 +654,7 @@ def respond_to?(string, include_all = false) | |
true | |
end | |
- def method_missing(*args) | |
+ ruby2_keywords def method_missing(*args) | |
nil | |
end | |
end | |
diff --git a/actionmailer/lib/action_mailer/message_delivery.rb b/actionmailer/lib/action_mailer/message_delivery.rb | |
index 1e5cab6d47..f858c592c0 100644 | |
--- a/actionmailer/lib/action_mailer/message_delivery.rb | |
+++ b/actionmailer/lib/action_mailer/message_delivery.rb | |
@@ -15,7 +15,7 @@ module ActionMailer | |
# Notifier.welcome(User.first).deliver_later # enqueue email delivery as a job through Active Job | |
# Notifier.welcome(User.first).message # a Mail::Message object | |
class MessageDelivery < Delegator | |
- def initialize(mailer_class, action, *args) #:nodoc: | |
+ ruby2_keywords def initialize(mailer_class, action, *args) #:nodoc: | |
@mailer_class, @action, @args = mailer_class, action, args | |
# The mail is only processed if we try to call any methods on it. | |
diff --git a/actionmailer/lib/action_mailer/rescuable.rb b/actionmailer/lib/action_mailer/rescuable.rb | |
index 5b567eb500..0915b1f774 100644 | |
--- a/actionmailer/lib/action_mailer/rescuable.rb | |
+++ b/actionmailer/lib/action_mailer/rescuable.rb | |
@@ -20,7 +20,7 @@ def handle_exceptions #:nodoc: | |
end | |
private | |
- def process(*) | |
+ ruby2_keywords def process(*) | |
handle_exceptions do | |
super | |
end | |
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb | |
index 3ff922029b..9db6b1ac03 100644 | |
--- a/actionpack/lib/abstract_controller/base.rb | |
+++ b/actionpack/lib/abstract_controller/base.rb | |
@@ -124,7 +124,7 @@ def method_added(name) | |
# | |
# ==== Returns | |
# * <tt>self</tt> | |
- def process(action, *args) | |
+ ruby2_keywords def process(action, *args) | |
@_action_name = action.to_s | |
unless action_name = _find_action_name(@_action_name) | |
@@ -191,7 +191,7 @@ def action_method?(name) | |
# | |
# Notice that the first argument is the method to be dispatched | |
# which is *not* necessarily the same as the action name. | |
- def process_action(method_name, *args) | |
+ ruby2_keywords def process_action(method_name, *args) | |
send_action(method_name, *args) | |
end | |
diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb | |
index 9ee6dabf31..a5f3083885 100644 | |
--- a/actionview/lib/action_view/rendering.rb | |
+++ b/actionview/lib/action_view/rendering.rb | |
@@ -34,7 +34,7 @@ def initialize | |
end | |
# Overwrite process to setup I18n proxy. | |
- def process(*) #:nodoc: | |
+ ruby2_keywords def process(*) #:nodoc: | |
old_config, I18n.config = I18n.config, I18nProxy.new(I18n.config, lookup_context) | |
super | |
ensure | |
diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb | |
index e08e30040b..a0bef12526 100644 | |
--- a/activejob/lib/active_job/arguments.rb | |
+++ b/activejob/lib/active_job/arguments.rb | |
@@ -52,6 +52,8 @@ def deserialize(arguments) | |
# :nodoc: | |
SYMBOL_KEYS_KEY = "_aj_symbol_keys" | |
# :nodoc: | |
+ RUBY2_KEYWORDS_KEY = "_aj_ruby2_keywords_keys" | |
+ # :nodoc: | |
WITH_INDIFFERENT_ACCESS_KEY = "_aj_hash_with_indifferent_access" | |
# :nodoc: | |
OBJECT_SERIALIZER_KEY = "_aj_serialized" | |
@@ -60,10 +62,30 @@ def deserialize(arguments) | |
RESERVED_KEYS = [ | |
GLOBALID_KEY, GLOBALID_KEY.to_sym, | |
SYMBOL_KEYS_KEY, SYMBOL_KEYS_KEY.to_sym, | |
+ RUBY2_KEYWORDS_KEY, RUBY2_KEYWORDS_KEY.to_sym, | |
OBJECT_SERIALIZER_KEY, OBJECT_SERIALIZER_KEY.to_sym, | |
WITH_INDIFFERENT_ACCESS_KEY, WITH_INDIFFERENT_ACCESS_KEY.to_sym, | |
] | |
- private_constant :PERMITTED_TYPES, :RESERVED_KEYS, :GLOBALID_KEY, :SYMBOL_KEYS_KEY, :WITH_INDIFFERENT_ACCESS_KEY | |
+ private_constant :PERMITTED_TYPES, :RESERVED_KEYS, :GLOBALID_KEY, :SYMBOL_KEYS_KEY, :RUBY2_KEYWORDS_KEY, :WITH_INDIFFERENT_ACCESS_KEY | |
+ | |
+ class Ruby2KeywordsUtil | |
+ def initialize(*args) | |
+ @args = args | |
+ end | |
+ attr_reader :args | |
+ | |
+ def self.flagged?(hash) | |
+ !self.new(*[hash]).args.last.equal?(hash) | |
+ end | |
+ | |
+ ruby2_keywords def flag(*args) | |
+ args.last | |
+ end | |
+ | |
+ def self.flag(hash) | |
+ self.new.flag(**hash) | |
+ end | |
+ end | |
def serialize_argument(argument) | |
case argument | |
@@ -79,6 +101,7 @@ def serialize_argument(argument) | |
symbol_keys = argument.each_key.grep(Symbol).map(&:to_s) | |
result = serialize_hash(argument) | |
result[SYMBOL_KEYS_KEY] = symbol_keys | |
+ result[RUBY2_KEYWORDS_KEY] = Ruby2KeywordsUtil.flagged?(argument) | |
result | |
when -> (arg) { arg.respond_to?(:permitted?) } | |
serialize_indifferent_hash(argument.to_h) | |
@@ -131,7 +154,9 @@ def deserialize_hash(serialized_hash) | |
if result.delete(WITH_INDIFFERENT_ACCESS_KEY) | |
result = result.with_indifferent_access | |
elsif symbol_keys = result.delete(SYMBOL_KEYS_KEY) | |
+ ruby2_keywords_flag = result.delete(RUBY2_KEYWORDS_KEY) | |
result = transform_symbol_keys(result, symbol_keys) | |
+ result = Ruby2KeywordsUtil.flag(**result) if ruby2_keywords_flag | |
end | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class Klass
attr_accessor :str
end
s1 = Klass.new #=> #Klass:0x401b3a38
s1.str = "Hello" #=> "Hello"
s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello">
s2.str[1,4] = "i" #=> "i"
s1.inspect #=> "#<Klass:0x401b3a38 @str="Hi">"
s2.inspect #=> "#<Klass:0x401b3998 @