Class: RailsWorkflow::Operation
Overview
Operation is a key building block for a Rails Workflow. This model is used to save operation meta data, describe relation with operation context etc.
Constant Summary
Constants included
from Status
Status::CANCELED, Status::DONE, Status::ERROR, Status::IN_PROGRESS, Status::NOT_STARTED, Status::ROLLBACK, Status::SKIPPED, Status::WAITING
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#manager ⇒ Object
31
32
33
|
# File 'app/models/rails_workflow/operation.rb', line 31
def manager
@manager ||= process.manager
end
|
Instance Method Details
#assigned_to?(user) ⇒ Boolean
45
46
47
|
# File 'app/models/rails_workflow/operation.rb', line 45
def assigned_to?(user)
assignment && assignment == user
end
|
#can_be_continued_by?(user, current_operation) ⇒ Boolean
69
70
71
72
73
|
# File 'app/models/rails_workflow/operation.rb', line 69
def can_be_continued_by?(user, current_operation)
waiting? &&
assigned_to?(user) &&
(current_operation.nil? || current_operation != self)
end
|
#can_be_started_by?(user) ⇒ Boolean
41
42
43
|
# File 'app/models/rails_workflow/operation.rb', line 41
def can_be_started_by?(user)
waiting? && can_be_assigned?(user) && assignment.nil?
end
|
#can_start? ⇒ Boolean
This method allows you to add requirements for operation to start. For example some operation can’t start because of some process or overall system conditions. By default any operation can start :)
57
58
59
|
# File 'app/models/rails_workflow/operation.rb', line 57
def can_start?
status.in? [Status::NOT_STARTED, Status::IN_PROGRESS]
end
|
#completable? ⇒ Boolean
65
66
67
|
# File 'app/models/rails_workflow/operation.rb', line 65
def completable?
child_process_done?
end
|
#completed? ⇒ Boolean
61
62
63
|
# File 'app/models/rails_workflow/operation.rb', line 61
def completed?
completed_statuses.include? status
end
|
#execute ⇒ Object
49
50
51
|
# File 'app/models/rails_workflow/operation.rb', line 49
def execute
true
end
|
#instruction ⇒ Object
27
28
29
|
# File 'app/models/rails_workflow/operation.rb', line 27
def instruction
template.instruction
end
|
#waiting? ⇒ Boolean
37
38
39
|
# File 'app/models/rails_workflow/operation.rb', line 37
def waiting?
status.in? Operation.user_ready_statuses
end
|