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, since) ⇒ Due

Returns a new instance of Due.



75
76
77
78
79
# File 'lib/lazylead/task/micromanager.rb', line 75

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

Instance Attribute Details

#issueObject (readonly)

Returns the value of attribute issue.



73
74
75
# File 'lib/lazylead/task/micromanager.rb', line 73

def issue
  @issue
end

#whenObject (readonly)

Returns the value of attribute when.



73
74
75
# File 'lib/lazylead/task/micromanager.rb', line 73

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)


83
84
85
86
# File 'lib/lazylead/task/micromanager.rb', line 83

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



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/lazylead/task/micromanager.rb', line 94

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"]
      dd = Lazylead::User.new(dd["author"])
    end
    dd
  end
end

#obsolete?Boolean

Give true when “Due Date” changes happens in past and its alert already sent.

Returns:

  • (Boolean)


89
90
91
# File 'lib/lazylead/task/micromanager.rb', line 89

def obsolete?
  @when < @since
end