diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-19 08:29:29 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-19 08:29:29 -0300 |
commit | 70419b5ec3016eb5592a1fb57c2098b261e82998 (patch) | |
tree | 96167136fefb9e38f2b5f9754d01b070b1aaa030 /lib/active_job/parameters.rb | |
parent | 3a932bf03c56eecf15ba89e6b46846b02b34ad47 (diff) | |
parent | 575a837de1ba4bc2d0ff41c9b5b6d10f011f4c7a (diff) | |
download | rails-70419b5ec3016eb5592a1fb57c2098b261e82998.tar.gz rails-70419b5ec3016eb5592a1fb57c2098b261e82998.tar.bz2 rails-70419b5ec3016eb5592a1fb57c2098b261e82998.zip |
Merge pull request #18 from mperham/param_whitelist
Whitelist legal job parameter types
Diffstat (limited to 'lib/active_job/parameters.rb')
-rw-r--r-- | lib/active_job/parameters.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/active_job/parameters.rb b/lib/active_job/parameters.rb index a4841abd1e..75de5bcae7 100644 --- a/lib/active_job/parameters.rb +++ b/lib/active_job/parameters.rb @@ -3,13 +3,17 @@ require 'active_support/core_ext/object/try' module ActiveJob class Parameters + TYPE_WHITELIST = [NilClass, Fixnum, Float, String, TrueClass, FalseClass, Hash, Array] + def self.serialize(params) - params.collect { |param| param.try(:global_id) || param } + params.collect do |param| + raise "Unsupported parameter type: #{param.class.name}" unless param.respond_to?(:global_id) || TYPE_WHITELIST.include?(param.class) + param.try(:global_id) || param + end end - + def self.deserialize(params) params.collect { |param| ActiveModel::GlobalLocator.locate(param) || param } end end end -
\ No newline at end of file |