Class: Ace::Assign::Models::AssignmentInfo
- Inherits:
-
Object
- Object
- Ace::Assign::Models::AssignmentInfo
- Defined in:
- lib/ace/assign/models/assignment_info.rb
Overview
Enriched assignment model combining Assignment + QueueState.
Pure data carrier with computed state (ATOM pattern). Wraps an assignment with its queue state to provide computed state, progress, and active step information.
Instance Attribute Summary collapse
-
#assignment ⇒ Object
readonly
Returns the value of attribute assignment.
-
#queue_state ⇒ Object
readonly
Returns the value of attribute queue_state.
Instance Method Summary collapse
-
#active_steps ⇒ Array<Step>
Active steps in queue order.
-
#completed? ⇒ Boolean
Check if assignment is completed.
- #created_at ⇒ Object
-
#current_step ⇒ String
Deterministic active step name kept for internal callers.
-
#id ⇒ Object
Delegate common accessors to assignment.
-
#initialize(assignment:, queue_state:) ⇒ AssignmentInfo
constructor
A new instance of AssignmentInfo.
- #name ⇒ Object
-
#next_step ⇒ Step?
Next pending workable step when nothing is active.
- #parent ⇒ Object
-
#progress ⇒ String
Progress string (done/total).
-
#state ⇒ Symbol
Computed assignment state.
-
#step_focus ⇒ String
Human-friendly active/next summary for compact tables.
- #task_ref ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(assignment:, queue_state:) ⇒ AssignmentInfo
Returns a new instance of AssignmentInfo.
22 23 24 25 |
# File 'lib/ace/assign/models/assignment_info.rb', line 22 def initialize(assignment:, queue_state:) @assignment = assignment @queue_state = queue_state end |
Instance Attribute Details
#assignment ⇒ Object (readonly)
Returns the value of attribute assignment.
18 19 20 |
# File 'lib/ace/assign/models/assignment_info.rb', line 18 def assignment @assignment end |
#queue_state ⇒ Object (readonly)
Returns the value of attribute queue_state.
18 19 20 |
# File 'lib/ace/assign/models/assignment_info.rb', line 18 def queue_state @queue_state end |
Instance Method Details
#active_steps ⇒ Array<Step>
Active steps in queue order.
45 46 47 |
# File 'lib/ace/assign/models/assignment_info.rb', line 45 def active_steps queue_state.active_steps end |
#completed? ⇒ Boolean
Check if assignment is completed
81 82 83 |
# File 'lib/ace/assign/models/assignment_info.rb', line 81 def completed? state == :completed end |
#created_at ⇒ Object
90 |
# File 'lib/ace/assign/models/assignment_info.rb', line 90 def created_at = assignment.created_at |
#current_step ⇒ String
Deterministic active step name kept for internal callers.
61 62 63 |
# File 'lib/ace/assign/models/assignment_info.rb', line 61 def current_step queue_state.current&.name || "-" end |
#id ⇒ Object
Delegate common accessors to assignment
86 |
# File 'lib/ace/assign/models/assignment_info.rb', line 86 def id = assignment.id |
#name ⇒ Object
87 |
# File 'lib/ace/assign/models/assignment_info.rb', line 87 def name = assignment.name |
#next_step ⇒ Step?
Next pending workable step when nothing is active.
52 53 54 55 56 |
# File 'lib/ace/assign/models/assignment_info.rb', line 52 def next_step return nil unless active_steps.empty? queue_state.next_workable end |
#parent ⇒ Object
91 |
# File 'lib/ace/assign/models/assignment_info.rb', line 91 def parent = assignment.parent |
#progress ⇒ String
Progress string (done/total)
37 38 39 40 |
# File 'lib/ace/assign/models/assignment_info.rb', line 37 def progress s = queue_state.summary "#{s[:done]}/#{s[:total]}" end |
#state ⇒ Symbol
Computed assignment state
30 31 32 |
# File 'lib/ace/assign/models/assignment_info.rb', line 30 def state queue_state.assignment_state end |
#step_focus ⇒ String
Human-friendly active/next summary for compact tables.
68 69 70 71 72 73 74 75 76 |
# File 'lib/ace/assign/models/assignment_info.rb', line 68 def step_focus if active_steps.any? active_steps.map(&:name).join(", ") elsif next_step "next: #{next_step.name}" else "-" end end |
#task_ref ⇒ Object
88 |
# File 'lib/ace/assign/models/assignment_info.rb', line 88 def task_ref = assignment.name |
#updated_at ⇒ Object
89 |
# File 'lib/ace/assign/models/assignment_info.rb', line 89 def updated_at = assignment.updated_at |