Class: Ductr::Store::JobSerializer::SerializedJob

Inherits:
Struct
  • Object
show all
Defined in:
lib/ductr/store/job_serializer.rb,
lib/ductr/store/job_serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_id, status, error) ⇒ SerializedJob

Returns a new instance of SerializedJob.

Parameters:

  • job_id (String)

    Active job’s job id

  • status (Symbol)

    Job’s status

  • error (Exception, nil)

    Job’s error



19
20
21
22
23
# File 'lib/ductr/store/job_serializer.rb', line 19

def initialize(job_id, status, error)
  @job_id = job_id
  @status = status
  @error = error
end

Instance Attribute Details

#errorException? (readonly)

Returns The job’s error if any.

Returns:

  • (Exception, nil)

    The job’s error if any



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ductr/store/job_serializer.rb', line 13

class SerializedJob < Struct
  #
  # @param [String] job_id Active job's job id
  # @param [Symbol] status Job's status
  # @param [Exception, nil] error Job's error
  #
  def initialize(job_id, status, error)
    @job_id = job_id
    @status = status
    @error = error
  end
end

#job_idString (readonly)

Returns The active job’s job id.

Returns:

  • (String)

    The active job’s job id



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ductr/store/job_serializer.rb', line 13

class SerializedJob < Struct
  #
  # @param [String] job_id Active job's job id
  # @param [Symbol] status Job's status
  # @param [Exception, nil] error Job's error
  #
  def initialize(job_id, status, error)
    @job_id = job_id
    @status = status
    @error = error
  end
end

#statusSymbol (readonly)

Returns The job’s status.

Returns:

  • (Symbol)

    The job’s status



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ductr/store/job_serializer.rb', line 13

class SerializedJob < Struct
  #
  # @param [String] job_id Active job's job id
  # @param [Symbol] status Job's status
  # @param [Exception, nil] error Job's error
  #
  def initialize(job_id, status, error)
    @job_id = job_id
    @status = status
    @error = error
  end
end

Instance Method Details

#stopped?Boolean

Determines whether the job has a ‘completed` or `failed` status.

Returns:

  • (Boolean)

    True when the status is ‘completed` or `failed`



42
43
44
# File 'lib/ductr/store/job_serializer.rb', line 42

def stopped?
  %i[completed failed].include? status
end