Module: Wheneverd::DSL::PeriodStrategy
- Defined in:
- lib/wheneverd/dsl/period_strategy.rb,
lib/wheneverd/dsl/period_strategy/base.rb,
lib/wheneverd/dsl/period_strategy/array_strategy.rb,
lib/wheneverd/dsl/period_strategy/string_strategy.rb,
lib/wheneverd/dsl/period_strategy/symbol_strategy.rb,
lib/wheneverd/dsl/period_strategy/duration_strategy.rb
Overview
Period parsing strategies for converting DSL period values into triggers.
Each strategy handles a specific type of period value and converts it into the appropriate trigger type.
Defined Under Namespace
Classes: ArrayStrategy, Base, DurationStrategy, StringStrategy, SymbolStrategy
Constant Summary collapse
- DEFAULT_STRATEGIES =
Default strategies in order of precedence.
[ DurationStrategy, ArrayStrategy, StringStrategy, SymbolStrategy ].freeze
Class Method Summary collapse
-
.for(period, path:) ⇒ Base
Find the strategy that handles the given period type.
Class Method Details
.for(period, path:) ⇒ Base
Find the strategy that handles the given period type.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/wheneverd/dsl/period_strategy.rb', line 30 def self.for(period, path:) strategy_class = DEFAULT_STRATEGIES.find do |klass| klass.new(path: path).handles?(period) end if strategy_class.nil? raise InvalidPeriodError.new("Unsupported period type: #{period.class}", path: path) end strategy_class.new(path: path) end |