Module: WithStatus

Extended by:
ActiveSupport::Concern
Included in:
Assignment
Defined in:
app/models/concerns/with_status.rb

Instance Method Summary collapse

Instance Method Details

#aborted?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/concerns/with_status.rb', line 13

def aborted?
  status == :aborted
end

#errored!(message) ⇒ Object



39
40
41
# File 'app/models/concerns/with_status.rb', line 39

def errored!(message)
  update! result: message, status: :errored
end

#passed!Object



27
28
29
# File 'app/models/concerns/with_status.rb', line 27

def passed!
  update! status: :passed
end

#passed?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/models/concerns/with_status.rb', line 9

def passed?
  status.passed?
end

#run_update!Object



17
18
19
20
21
22
23
24
25
# File 'app/models/concerns/with_status.rb', line 17

def run_update!
  running!
  begin
    update! yield
  rescue => e
    errored! e.message
    raise e
  end
end

#running!Object



31
32
33
34
35
36
37
# File 'app/models/concerns/with_status.rb', line 31

def running!
  update! status: :running,
          result: nil,
          test_results: nil,
          expectation_results: [],
          manual_evaluation_comment: nil
end