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
45
46
47
|
# File 'app/models/rails_workflow/operation.rb', line 45
def manager
@manager ||= process.manager
end
|
Instance Method Details
#assigned_to?(user) ⇒ Boolean
59
60
61
|
# File 'app/models/rails_workflow/operation.rb', line 59
def assigned_to?(user)
assignment && assignment == user
end
|
#can_be_continued_by?(user, current_operation) ⇒ Boolean
83
84
85
86
87
|
# File 'app/models/rails_workflow/operation.rb', line 83
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
55
56
57
|
# File 'app/models/rails_workflow/operation.rb', line 55
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 :)
71
72
73
|
# File 'app/models/rails_workflow/operation.rb', line 71
def can_start?
status.in? [Status::NOT_STARTED, Status::IN_PROGRESS]
end
|
#completable? ⇒ Boolean
79
80
81
|
# File 'app/models/rails_workflow/operation.rb', line 79
def completable?
child_process_done?
end
|
#completed? ⇒ Boolean
75
76
77
|
# File 'app/models/rails_workflow/operation.rb', line 75
def completed?
completed_statuses.include? status
end
|
#execute ⇒ Object
63
64
65
|
# File 'app/models/rails_workflow/operation.rb', line 63
def execute
true
end
|
#instruction ⇒ Object
37
38
39
|
# File 'app/models/rails_workflow/operation.rb', line 37
def instruction
template.instruction
end
|
#tag ⇒ Object
41
42
43
|
# File 'app/models/rails_workflow/operation.rb', line 41
def tag
read_attribute(:tag) || template.tag
end
|
#waiting? ⇒ Boolean
51
52
53
|
# File 'app/models/rails_workflow/operation.rb', line 51
def waiting?
status.in? Operation.user_ready_statuses
end
|