diff options
author | Bernie Chiu <bernie@shoplineapp.com> | 2018-10-05 15:26:02 +0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-11-19 17:38:29 -0500 |
commit | 945fdd76925c9f615bf016717c4c8db2b2955357 (patch) | |
tree | 1b628cd8aad89c3fa444862266309149dda02bad /activejob/lib | |
parent | df9dd4801b3c8a781d53680a3f5ec7dd0f7515e3 (diff) | |
download | rails-945fdd76925c9f615bf016717c4c8db2b2955357.tar.gz rails-945fdd76925c9f615bf016717c4c8db2b2955357.tar.bz2 rails-945fdd76925c9f615bf016717c4c8db2b2955357.zip |
Permit ActionController::Parameters for serializable Hash
Diffstat (limited to 'activejob/lib')
-rw-r--r-- | activejob/lib/active_job/arguments.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb index ffc57dae84..fa58c50ed0 100644 --- a/activejob/lib/active_job/arguments.rb +++ b/activejob/lib/active_job/arguments.rb @@ -75,14 +75,14 @@ module ActiveJob when Array argument.map { |arg| serialize_argument(arg) } when ActiveSupport::HashWithIndifferentAccess - result = serialize_hash(argument) - result[WITH_INDIFFERENT_ACCESS_KEY] = serialize_argument(true) - result + serialize_indifferent_hash(argument) when Hash symbol_keys = argument.each_key.grep(Symbol).map(&:to_s) result = serialize_hash(argument) result[SYMBOL_KEYS_KEY] = symbol_keys result + when -> (arg) { arg.respond_to?(:permitted?) } + serialize_indifferent_hash(argument.to_h) else Serializers.serialize(argument) end @@ -148,6 +148,12 @@ module ActiveJob end end + def serialize_indifferent_hash(indifferent_hash) + result = serialize_hash(indifferent_hash) + result[WITH_INDIFFERENT_ACCESS_KEY] = serialize_argument(true) + result + end + def transform_symbol_keys(hash, symbol_keys) # NOTE: HashWithIndifferentAccess#transform_keys always # returns stringified keys with indifferent access |