Module: Aeternitas::PollingFrequency

Defined in:
lib/aeternitas/polling_frequency.rb

Overview

Stores default polling frequency calculation methods.

Constant Summary collapse

HOURLY =
->(context) { Time.now + 1.hour }
DAILY =
->(context) { Time.now + 1.day  }
WEEKLY =
->(context) { Time.now + 1.week }
MONTHLY =
->(context) { Time.now + 1.month }

Class Method Summary collapse

Class Method Details

.by_name(name) ⇒ Lambda

Retrieves the build-in polling frequency methods by name.

Parameters:

  • name (Symbol)

    the frequency method

Returns:

  • (Lambda)

    Polling frequency method

Raises:

  • (ArgumentError)

    if the preset does not exist



14
15
16
17
18
19
20
21
22
# File 'lib/aeternitas/polling_frequency.rb', line 14

def self.by_name(name)
  case name
  when :hourly then HOURLY
  when :daily then DAILY
  when :weekly then WEEKLY
  when :monthly then MONTHLY
  else raise(ArgumentError, "Unknown polling frequency: #{name}")
  end
end