diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-02-09 17:27:01 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-02-14 13:10:08 -0500 |
commit | a5f7357a3dff2617ba13a274feb8d8ac2492f26a (patch) | |
tree | 0f1674dd837b9ac8d6027c906be8111dd340ef96 | |
parent | 2fe467091b3743627d52a3e2ae357f0b5fd6d157 (diff) | |
download | rails-a5f7357a3dff2617ba13a274feb8d8ac2492f26a.tar.gz rails-a5f7357a3dff2617ba13a274feb8d8ac2492f26a.tar.bz2 rails-a5f7357a3dff2617ba13a274feb8d8ac2492f26a.zip |
Add configuration to set custom serializers
-rw-r--r-- | activejob/lib/active_job/railtie.rb | 6 | ||||
-rw-r--r-- | guides/source/configuring.md | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/activejob/lib/active_job/railtie.rb b/activejob/lib/active_job/railtie.rb index 7b0742a6d2..427ad1e3af 100644 --- a/activejob/lib/active_job/railtie.rb +++ b/activejob/lib/active_job/railtie.rb @@ -7,11 +7,17 @@ module ActiveJob # = Active Job Railtie class Railtie < Rails::Railtie # :nodoc: config.active_job = ActiveSupport::OrderedOptions.new + config.active_job.custom_serializers = [] initializer "active_job.logger" do ActiveSupport.on_load(:active_job) { self.logger = ::Rails.logger } end + initializer "active_job.custom_serializers" do |app| + custom_serializers = app.config.active_job.delete(:custom_serializers) + ActiveJob::Serializers.add_serializers custom_serializers + end + initializer "active_job.set_configs" do |app| options = app.config.active_job options.queue_adapter ||= :async diff --git a/guides/source/configuring.md b/guides/source/configuring.md index b0f39e7ab5..fd747c1686 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -741,6 +741,8 @@ There are a few configuration options available in Active Support: * `config.active_job.logger` accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then used to log information from Active Job. You can retrieve this logger by calling `logger` on either an Active Job class or an Active Job instance. Set to `nil` to disable logging. +* `config.active_job.custom_serializers` allows to set custom argument serializers. Defaults to `[]`. + ### Configuring Action Cable * `config.action_cable.url` accepts a string for the URL for where |