Skip to content

Commit

Permalink
Add configuration to set custom serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Feb 14, 2018
1 parent 2fe4670 commit a5f7357
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions activejob/lib/active_job/railtie.rb
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions guides/source/configuring.md
Expand Up @@ -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
Expand Down

0 comments on commit a5f7357

Please sign in to comment.