Class: Lazylead::Task::Due

Inherits:
Object
  • Object
show all
Defined in:
lib/lazylead/task/micromanager.rb

Overview

Instance of “Due” history item for the particular ticket.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue, allowed) ⇒ Due

Returns a new instance of Due.



57
58
59
60
# File 'lib/lazylead/task/micromanager.rb', line 57

def initialize(issue, allowed)
  @issue = issue
  @allowed = allowed
end

Instance Attribute Details

#issueObject (readonly)

Returns the value of attribute issue.



55
56
57
# File 'lib/lazylead/task/micromanager.rb', line 55

def issue
  @issue
end

#whenObject (readonly)

Returns the value of attribute when.



55
56
57
# File 'lib/lazylead/task/micromanager.rb', line 55

def when
  @when
end

Instance Method Details

#illegal?Boolean

Gives true when last change of “Due Date” field was done

by not authorized person.

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/lazylead/task/micromanager.rb', line 64

def illegal?
  return false if @issue.assignee.id.eql?(last.id)
  @allowed.none? { |a| a.eql? last.id }
end

#lastObject

Detect details about last change of “Due Date” to non-null value



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/lazylead/task/micromanager.rb', line 70

def last
  @last ||= begin
    dd = @issue.history
               .reverse
               .find { |h| h["items"].any? { |i| i["field"] == "duedate" } }
    if dd.nil? && !@issue.duedate.nil?
      @when = @issue["created"]
      dd = @issue.reporter
    else
      @when = dd["created"].to_date
      dd = Lazylead::User.new(dd["author"])
    end
    dd
  end
end