Class: Jira::Command::Rename

Inherits:
Base
  • Object
show all
Defined in:
lib/jira/commands/rename.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ticket) ⇒ Rename

Returns a new instance of Rename.



18
19
20
# File 'lib/jira/commands/rename.rb', line 18

def initialize(ticket)
  self.ticket = ticket
end

Instance Attribute Details

#ticketObject

Returns the value of attribute ticket.



16
17
18
# File 'lib/jira/commands/rename.rb', line 16

def ticket
  @ticket
end

Instance Method Details

#on_failureObject



43
44
45
# File 'lib/jira/commands/rename.rb', line 43

def on_failure
  ->{ puts "No change made to ticket #{ticket}." }
end

#on_successObject



39
40
41
# File 'lib/jira/commands/rename.rb', line 39

def on_success
  ->{ puts "Successfully updated ticket #{ticket}'s summary." }
end

#paramsObject



31
32
33
34
35
36
37
# File 'lib/jira/commands/rename.rb', line 31

def params
  {
    fields: {
      summary: summary
    }
  }
end

#runObject



22
23
24
25
26
27
28
29
# File 'lib/jira/commands/rename.rb', line 22

def run
  return if ticket.empty?
  return if summary.empty?
  api.patch "issue/#{ticket}",
    params:  params,
    success: on_success,
    failure: on_failure
end

#summaryObject



47
48
49
# File 'lib/jira/commands/rename.rb', line 47

def summary
  @summary ||= io.ask("New summary for ticket #{ticket}:")
end