Class: Dorsale::Flyboy::Task

Inherits:
ApplicationRecord show all
Includes:
Agilibox::Search
Defined in:
app/models/dorsale/flyboy/task.rb

Defined Under Namespace

Classes: Copy, Snoozer

Constant Summary collapse

REMINDER_TYPES =
%w(duration custom)
REMINDER_UNITS =
%w(days weeks months)
STATES =
%w(done undone ontime onwarning onalert)

Instance Method Summary collapse

Methods inherited from ApplicationRecord

last_created

Instance Method Details

#assign_default_valuesObject



77
78
79
80
81
# File 'app/models/dorsale/flyboy/task.rb', line 77

def assign_default_values
  assign_default :progress, 0
  assign_default :done,     false
  assign_default :term,     Time.zone.now.to_date.end_of_week
end

#reminder_duration=(value) ⇒ Object



97
98
99
100
# File 'app/models/dorsale/flyboy/task.rb', line 97

def reminder_duration=(value)
  super
  auto_update_reminder_date
end

#reminder_type=(value) ⇒ Object



92
93
94
95
# File 'app/models/dorsale/flyboy/task.rb', line 92

def reminder_type=(value)
  super
  auto_update_reminder_date
end

#reminder_unit=(value) ⇒ Object



102
103
104
105
# File 'app/models/dorsale/flyboy/task.rb', line 102

def reminder_unit=(value)
  super
  auto_update_reminder_date
end

#snoozerObject



83
84
85
# File 'app/models/dorsale/flyboy/task.rb', line 83

def snoozer
  @snoozer ||= Snoozer.new(self)
end

#stateObject



20
21
22
23
24
25
# File 'app/models/dorsale/flyboy/task.rb', line 20

def state
  return "done"      if done
  return "onalert"   if term          && term          <= Time.zone.now.to_date
  return "onwarning" if reminder_date && reminder_date <= Time.zone.now.to_date
  return "ontime"
end

#term=(value) ⇒ Object



87
88
89
90
# File 'app/models/dorsale/flyboy/task.rb', line 87

def term=(value)
  super
  auto_update_reminder_date
end