Class: Lazylead::ChangedTo
- Inherits:
-
Object
- Object
- Lazylead::ChangedTo
- Defined in:
- lib/lazylead/task/alert/changed_to.rb
Overview
Gives true when ticket status changed to expected status(es).
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(field, expected) ⇒ ChangedTo
constructor
A new instance of ChangedTo.
-
#last_change(issue) ⇒ Object
Detect the last change of expected field in issue history.
- #passed(issue, opts) ⇒ Object
Constructor Details
#initialize(field, expected) ⇒ ChangedTo
Returns a new instance of ChangedTo.
32 33 34 35 |
# File 'lib/lazylead/task/alert/changed_to.rb', line 32 def initialize(field, expected) @field = field @expected = expected end |
Instance Method Details
#last_change(issue) ⇒ Object
Detect the last change of expected field in issue history
44 45 46 47 48 49 |
# File 'lib/lazylead/task/alert/changed_to.rb', line 44 def last_change(issue) issue.history .reverse .find { |h| h["items"].any? { |i| i["field"] == @field } }["items"] .find { |h| h["field"] == @field }["toString"] end |
#passed(issue, opts) ⇒ Object
37 38 39 40 41 |
# File 'lib/lazylead/task/alert/changed_to.rb', line 37 def passed(issue, opts) return false if issue.nil? || opts.nil? || opts[@expected].nil? || @field.nil? last = last_change(issue) opts.slice(@expected, ",").any? { |s| s.eql? last } end |