Class: MotherBrain::JobRecord
- Inherits:
-
Object
- Object
- MotherBrain::JobRecord
- Includes:
- MB::Job::States
- Defined in:
- lib/mb/job_record.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_buffer ⇒ Object
readonly
Returns the value of attribute status_buffer.
-
#time_end ⇒ Object
readonly
Returns the value of attribute time_end.
-
#time_start ⇒ Object
readonly
Returns the value of attribute time_start.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(job) ⇒ JobRecord
constructor
A new instance of JobRecord.
- #to_hash ⇒ Hash
- #to_json(options = {}) ⇒ String
-
#update(job) ⇒ self
Update the instantiated JobRecord with the attributes of the given Job.
Constructor Details
#initialize(job) ⇒ JobRecord
Returns a new instance of JobRecord.
17 18 19 20 |
# File 'lib/mb/job_record.rb', line 17 def initialize(job) @id = job.id mass_assign(job) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/mb/job_record.rb', line 5 def id @id end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
7 8 9 |
# File 'lib/mb/job_record.rb', line 7 def result @result end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
8 9 10 |
# File 'lib/mb/job_record.rb', line 8 def state @state end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/mb/job_record.rb', line 9 def status @status end |
#status_buffer ⇒ Object (readonly)
Returns the value of attribute status_buffer.
10 11 12 |
# File 'lib/mb/job_record.rb', line 10 def status_buffer @status_buffer end |
#time_end ⇒ Object (readonly)
Returns the value of attribute time_end.
14 15 16 |
# File 'lib/mb/job_record.rb', line 14 def time_end @time_end end |
#time_start ⇒ Object (readonly)
Returns the value of attribute time_start.
13 14 15 |
# File 'lib/mb/job_record.rb', line 13 def time_start @time_start end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/mb/job_record.rb', line 11 def type @type end |
Instance Method Details
#to_hash ⇒ Hash
34 35 36 37 38 39 40 41 42 43 44 |
# 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 = {}) ⇒ String
50 51 52 |
# File 'lib/mb/job_record.rb', line 50 def to_json( = {}) MultiJson.encode(self.to_hash, ) end |
#update(job) ⇒ self
Update the instantiated JobRecord with the attributes of the given Job
28 29 30 31 |
# File 'lib/mb/job_record.rb', line 28 def update(job) mass_assign(job) self end |