Sha256: 065b34ed71065fe1cb0103dd6ef458aa74d0f9549eec8c1f0d31f8063de6279a

Contents?: true

Size: 591 Bytes

Versions: 5

Compression:

Stored size: 591 Bytes

Contents

class CacheKeeper::BaseJob < ActiveJob::Base
  discard_on StandardError

  private

  # Monkey patch ActiveJob::Core#serialize_arguments to use CacheKeeper::WhateverSerializer
  # in case there's no serializer for the argument. I'm doing it this way because I don't
  # want to register the serializer as it would affect the whole application.
  def serialize_arguments(arguments)
    arguments.map do |argument|
      ActiveJob::Arguments.send :serialize_argument, argument
    rescue ActiveJob::SerializationError
      CacheKeeper::WhateverSerializer.serialize argument
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cache_keeper-0.2.1 app/jobs/cache_keeper/base_job.rb
cache_keeper-0.2.0 app/jobs/cache_keeper/base_job.rb
cache_keeper-0.1.2 app/jobs/cache_keeper/base_job.rb
cache_keeper-0.1.1 app/jobs/cache_keeper/base_job.rb
cache_keeper-0.1.0 app/jobs/cache_keeper/base_job.rb