class MotherBrain::JobRecord

Attributes

id[R]
result[R]
state[R]
status[R]
status_buffer[R]
time_end[R]
time_start[R]
type[R]

Public Class Methods

new(job) click to toggle source

@param [Job] job

# File lib/mb/job_record.rb, line 17
def initialize(job)
  @id = job.id
  mass_assign(job)
end

Public Instance Methods

to_hash() click to toggle source

@return [Hash]

# File lib/mb/job_record.rb, line 34
def to_hash
  {
    id: id,
    type: type,
    state: state,
    status: status,
    result: result,
    time_start: time_start,
    time_end: time_end
  }
end
to_json(options = {}) click to toggle source

@param [Hash] options

a set of options to pass to MultiJson.encode

@return [String]

# File lib/mb/job_record.rb, line 50
def to_json(options = {})
  MultiJson.encode(self.to_hash, options)
end
update(job) click to toggle source

Update the instantiated JobRecord with the attributes of the given Job

@param [Job] job

the updated job to update the record with

@return [self]

# File lib/mb/job_record.rb, line 28
def update(job)
  mass_assign(job)
  self
end

Private Instance Methods

mass_assign(job) click to toggle source

@param [Job] job

# File lib/mb/job_record.rb, line 57
def mass_assign(job)
  @result        = job.result
  @state         = job.state
  @status        = job.status
  @status_buffer = job.status_buffer
  @time_end      = job.time_end
  @time_start    = job.time_start
  @type          = job.type
end