Class: Lazylead::Task::Assignee
- Inherits:
-
Object
- Object
- Lazylead::Task::Assignee
- Defined in:
- lib/lazylead/task/assignment.rb
Overview
Instance of “Assignee” history item for the particular ticket.
Instance Attribute Summary collapse
-
#issue ⇒ Object
readonly
Returns the value of attribute issue.
Instance Method Summary collapse
-
#add_label(name = "LL.IllegalChangeOfAssignee") ⇒ Object
Mark ticket with particular label.
-
#illegal? ⇒ Boolean
Gives true when last change of “Assignee” field was done by not authorized person.
-
#initialize(issue, allowed, silent) ⇒ Assignee
constructor
A new instance of Assignee.
-
#last ⇒ Object
Detect details about last change of “Assignee” to non-null value.
-
#to ⇒ Object
The name of current assignee for ticket.
Constructor Details
#initialize(issue, allowed, silent) ⇒ Assignee
Returns a new instance of Assignee.
59 60 61 62 63 |
# File 'lib/lazylead/task/assignment.rb', line 59 def initialize(issue, allowed, silent) @issue = issue @allowed = allowed @silent = silent end |
Instance Attribute Details
#issue ⇒ Object (readonly)
Returns the value of attribute issue.
57 58 59 |
# File 'lib/lazylead/task/assignment.rb', line 57 def issue @issue end |
Instance Method Details
#add_label(name = "LL.IllegalChangeOfAssignee") ⇒ Object
Mark ticket with particular label
82 83 84 |
# File 'lib/lazylead/task/assignment.rb', line 82 def add_label(name = "LL.IllegalChangeOfAssignee") @issue.add_label(name) unless @silent end |
#illegal? ⇒ Boolean
Gives true when last change of “Assignee” field was done
by not authorized person.
67 68 69 70 |
# File 'lib/lazylead/task/assignment.rb', line 67 def illegal? return false if last.nil? || @issue.assignee.id.eql?(last["author"]["name"]) @allowed.none? { |a| a.eql? last["author"]["name"] } end |
#last ⇒ Object
Detect details about last change of “Assignee” to non-null value
73 74 75 76 77 78 79 |
# File 'lib/lazylead/task/assignment.rb', line 73 def last @last ||= issue.history.reverse.find do |h| h["items"].any? do |i| i["field"] == "assignee" end end end |
#to ⇒ Object
The name of current assignee for ticket
87 88 89 |
# File 'lib/lazylead/task/assignment.rb', line 87 def to @issue.fields["assignee"]["displayName"] end |