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.
61 62 63 64 65 |
# File 'lib/lazylead/task/assignment.rb', line 61 def initialize(issue, allowed, silent) @issue = issue @allowed = allowed @silent = silent end |
Instance Attribute Details
#issue ⇒ Object (readonly)
Returns the value of attribute issue.
59 60 61 |
# File 'lib/lazylead/task/assignment.rb', line 59 def issue @issue end |
Instance Method Details
#add_label(name = "LL.IllegalChangeOfAssignee") ⇒ Object
Mark ticket with particular label
86 87 88 |
# File 'lib/lazylead/task/assignment.rb', line 86 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.
69 70 71 72 73 74 |
# File 'lib/lazylead/task/assignment.rb', line 69 def illegal? @allowed.none? do |a| return false if last.nil? a == last["author"]["name"] end end |
#last ⇒ Object
Detect details about last change of “Assignee” to non-null value
77 78 79 80 81 82 83 |
# File 'lib/lazylead/task/assignment.rb', line 77 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
91 92 93 |
# File 'lib/lazylead/task/assignment.rb', line 91 def to @issue.fields["assignee"]["name"] end |