Class: Rallycat::Update
- Inherits:
-
Object
- Object
- Rallycat::Update
- Defined in:
- lib/rallycat/update.rb
Instance Method Summary collapse
-
#initialize(api) ⇒ Update
constructor
A new instance of Update.
- #task(task_number, attributes) ⇒ Object
Constructor Details
#initialize(api) ⇒ Update
Returns a new instance of Update.
4 5 6 |
# File 'lib/rallycat/update.rb', line 4 def initialize(api) @api = api end |
Instance Method Details
#task(task_number, attributes) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rallycat/update.rb', line 8 def task(task_number, attributes) task = find_task(task_number) # When we set the state of the task and we don't explicitly set it to # blocked we want to remove the block. In our workflow, when you change # the state of the task it is also unblocked. if attributes[:state] && !attributes[:blocked] attributes[:blocked] = false end # The value in attributes[:owner] should be equal to the desired owner's # display name in Rally. We need to fetch the user in order to get their # login_name. The login_name is needed in order to set the owner # attribute of a task. # # We decided it would be easier for the user to enter 'John Smith' # instead of '[email protected]'. if display_name = attributes[:owner] login_name = find_user(display_name) attributes[:owner] = login_name end # If the task is marked as 'Complete', we should remove the remaining # hours. if attributes[:state] == "Completed" attributes[:to_do] = 0.0 end task.update(attributes) = [] if attributes[:state] << (task_number, attributes[:state]) end if attributes[:blocked] << (task_number) end if attributes[:owner] << (task_number, display_name) end .join("\n") end |