module ActiveJob::Core - activejob-4.2.4 Documentation

# module ActiveJob::Core

### Public Class Methods

new(*arguments) click to toggle source

Creates a new job instance. Takes the arguments that will be passed to the perform method.

    # File lib/active_job/core.rb, line 59
    def initialize(*arguments)
      @arguments  = arguments
      @job_id     = SecureRandom.uuid
      @queue_name = self.class.queue_name
    end

### Public Instance Methods

serialize() click to toggle source

Returns a hash with the job data that can safely be passed to the queueing adapter.

    # File lib/active_job/core.rb, line 67
    def serialize
      {
        'job_class'  => self.class.name,
        'job_id'     => job_id,
        'queue_name' => queue_name,
        'arguments'  => serialize_arguments(arguments),
        'locale'     => I18n.locale
      }
    end

### Private Instance Methods

deserialize_arguments(serialized_args) click to toggle source

    # File lib/active_job/core.rb, line 89
    def deserialize_arguments(serialized_args)
      Arguments.deserialize(serialized_args)
    end

deserialize_arguments_if_needed() click to toggle source

    # File lib/active_job/core.rb, line 78
    def deserialize_arguments_if_needed
      if defined?(@serialized_arguments) && @serialized_arguments.present?
        @arguments = deserialize_arguments(@serialized_arguments)
        @serialized_arguments = nil
      end
    end

serialize_arguments(serialized_args) click to toggle source

    # File lib/active_job/core.rb, line 85
    def serialize_arguments(serialized_args)
      Arguments.serialize(serialized_args)
    end