Sha256: 6c4054a3e7e6a5620a9bc54e942fa2e55358bb45700518b181367b151011c053

Contents?: true

Size: 739 Bytes

Versions: 12

Compression:

Stored size: 739 Bytes

Contents

class Dorsale::Flyboy::Task::Snoozer < ::Dorsale::Service
  attr_reader :task

  def initialize(task)
    @task = task
  end

  def call
    snooze
  end

  def snooze
    if task.term
      task.term = task.term + snooze_term_value
    end

    if task.reminder_type == "custom"
      task.reminder_date = task.reminder_date + snooze_reminder_value
    end

    task.save
  end

  def snoozable?
    if task.done?
      false
    elsif task.reminder_date
      task.reminder_date <= current_date
    elsif task.term
      task.term <= current_date
    else
      false
    end
  end

  private

  def current_date
    Time.zone.now.to_date
  end

  def snooze_term_value
    1.week
  end

  def snooze_reminder_value
    1.week
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dorsale-3.8.1 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.8.0 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.7.8 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.7.7 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.7.6 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.7.5 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.7.4 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.7.2 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.7.1 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.7.0 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.6.1 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.6.0 app/services/dorsale/flyboy/task/snoozer.rb