Class: Jira::Command::Assign
Instance Attribute Summary collapse
-
#ticket ⇒ Object
Returns the value of attribute ticket.
Instance Method Summary collapse
- #assignee ⇒ Object
-
#initialize(ticket) ⇒ Assign
constructor
A new instance of Assign.
- #name ⇒ Object
- #on_failure ⇒ Object
- #on_success ⇒ Object
- #params ⇒ Object
- #path ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(ticket) ⇒ Assign
Returns a new instance of Assign.
18 19 20 |
# File 'lib/jira/commands/assign.rb', line 18 def initialize(ticket) self.ticket = ticket end |
Instance Attribute Details
#ticket ⇒ Object
Returns the value of attribute ticket.
16 17 18 |
# File 'lib/jira/commands/assign.rb', line 16 def ticket @ticket end |
Instance Method Details
#assignee ⇒ Object
54 55 56 57 58 59 |
# File 'lib/jira/commands/assign.rb', line 54 def assignee @assignee ||= ( assignee = io.ask('Assignee?', default: 'auto') assignee == 'auto' ? '-1' : assignee ) end |
#name ⇒ Object
50 51 52 |
# File 'lib/jira/commands/assign.rb', line 50 def name assignee == '-1' ? 'default user' : "'#{assignee}'" end |
#on_failure ⇒ Object
35 36 37 38 39 40 |
# File 'lib/jira/commands/assign.rb', line 35 def on_failure ->(json) do = (json['errors'] || {})['assignee'] puts || "Ticket #{ticket} was not assigned." end end |
#on_success ⇒ Object
29 30 31 32 33 |
# File 'lib/jira/commands/assign.rb', line 29 def on_success -> do puts "Ticket #{ticket} assigned to #{name}." end end |
#params ⇒ Object
46 47 48 |
# File 'lib/jira/commands/assign.rb', line 46 def params { name: assignee } end |
#path ⇒ Object
42 43 44 |
# File 'lib/jira/commands/assign.rb', line 42 def path "issue/#{ticket}/assignee" end |
#run ⇒ Object
22 23 24 25 26 27 |
# File 'lib/jira/commands/assign.rb', line 22 def run api.patch path, params: params, success: on_success, failure: on_failure end |