Class: Karousel::Job
- Inherits:
-
Object
- Object
- Karousel::Job
- Defined in:
- lib/karousel/job.rb
Instance Attribute Summary collapse
-
#client_job ⇒ Object
readonly
Returns the value of attribute client_job.
Instance Method Summary collapse
- #finished? ⇒ Boolean
-
#initialize(client_job) ⇒ Job
constructor
STATUS = { init: 1, sent: 2, success: 3, failure: 4 }.
- #process ⇒ Object
- #send ⇒ Object
- #status ⇒ Object
- #status=(new_status) ⇒ Object
Constructor Details
Instance Attribute Details
#client_job ⇒ Object (readonly)
Returns the value of attribute client_job.
3 4 5 |
# File 'lib/karousel/job.rb', line 3 def client_job @client_job end |
Instance Method Details
#finished? ⇒ Boolean
34 35 36 |
# File 'lib/karousel/job.rb', line 34 def finished? @client_job.finished? end |
#process ⇒ Object
38 39 40 41 42 |
# File 'lib/karousel/job.rb', line 38 def process is_ok = @client_job.process self.status = (is_ok ? STATUS[:success] : STATUS[:failure]) is_ok end |
#send ⇒ Object
28 29 30 31 32 |
# File 'lib/karousel/job.rb', line 28 def send is_ok = @client_job.send self.status = (is_ok ? STATUS[:sent] : STATUS[:failure]) is_ok end |
#status ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/karousel/job.rb', line 13 def status @status = @client_job.status unless [1,2,3,4].include?(@status) raise TypeError.new('Status must be an integer between 1 and 4') end @status end |
#status=(new_status) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/karousel/job.rb', line 21 def status= (new_status) unless [1,2,3,4].include?(new_status) raise TypeError.new('Status must be an integer between 1 and 4') end @client_job.status = new_status end |