Sha256: 23b4ecb3eff9a6c030a86e614673ada1828c90ee9ab0b2c8d0b7a0a5ffb625a9

Contents?: true

Size: 737 Bytes

Versions: 15

Compression:

Stored size: 737 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

    return 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
    Date.current
  end

  def snooze_term_value
    1.week
  end

  def snooze_reminder_value
    1.week
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dorsale-3.14.9 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.8 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.7 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.6 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.5 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.4 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.3 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.2 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.1 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.14.0 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.13.0 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.12.0 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.11.0 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.10.3 app/services/dorsale/flyboy/task/snoozer.rb
dorsale-3.10.2 app/services/dorsale/flyboy/task/snoozer.rb