Class: CommandProposal::Task
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- CommandProposal::Task
- Defined in:
- app/models/command_proposal/task.rb
Overview
has_many :iterations text :name text :friendly_id text :description integer :session_type datetime :last_executed_at
Instance Attribute Summary collapse
-
#skip_approval ⇒ Object
Returns the value of attribute skip_approval.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #approved? ⇒ Boolean
- #code=(new_code) ⇒ Object
- #completed_at ⇒ Object
- #current_iteration ⇒ Object
- #current_iteration_at ⇒ Object
- #current_iteration_by ⇒ Object
- #first_iteration ⇒ Object
- #lines ⇒ Object
- #primary_iteration ⇒ Object
- #started_at ⇒ Object
- #to_param ⇒ Object
Instance Attribute Details
#skip_approval ⇒ Object
Returns the value of attribute skip_approval.
10 11 12 |
# File 'app/models/command_proposal/task.rb', line 10 def skip_approval @skip_approval end |
#user ⇒ Object
Returns the value of attribute user.
10 11 12 |
# File 'app/models/command_proposal/task.rb', line 10 def user @user end |
Instance Method Details
#approved? ⇒ Boolean
61 62 63 |
# File 'app/models/command_proposal/task.rb', line 61 def approved? primary_iteration&.approved_at? end |
#code=(new_code) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/models/command_proposal/task.rb', line 93 def code=(new_code) if skip_approval iterations.create( code: new_code, requester: user, status: :approved, approver: user, approved_at: Time.current ) else iterations.create(code: new_code, requester: user) end end |
#completed_at ⇒ Object
89 90 91 |
# File 'app/models/command_proposal/task.rb', line 89 def completed_at iterations.maximum(:completed_at) end |
#current_iteration ⇒ Object
69 70 71 |
# File 'app/models/command_proposal/task.rb', line 69 def current_iteration ordered_iterations.first end |
#current_iteration_at ⇒ Object
77 78 79 |
# File 'app/models/command_proposal/task.rb', line 77 def current_iteration_at current_iteration&.completed_at end |
#current_iteration_by ⇒ Object
81 82 83 |
# File 'app/models/command_proposal/task.rb', line 81 def current_iteration_by current_iteration&.requester_name end |
#first_iteration ⇒ Object
65 66 67 |
# File 'app/models/command_proposal/task.rb', line 65 def first_iteration ordered_iterations.last end |
#lines ⇒ Object
53 54 55 |
# File 'app/models/command_proposal/task.rb', line 53 def lines iterations.order(created_at: :asc).where.not(id: first_iteration.id) end |
#primary_iteration ⇒ Object
73 74 75 |
# File 'app/models/command_proposal/task.rb', line 73 def primary_iteration console? ? first_iteration : current_iteration end |
#started_at ⇒ Object
85 86 87 |
# File 'app/models/command_proposal/task.rb', line 85 def started_at iterations.minimum(:started_at) end |
#to_param ⇒ Object
57 58 59 |
# File 'app/models/command_proposal/task.rb', line 57 def to_param friendly_id || generate_friendly_id end |