Module: SayWhen::Utils

Included in:
Scheduler
Defined in:
lib/say_when/utils.rb

Instance Method Summary collapse

Instance Method Details

#load_strategy(strategy_type, strategy) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/say_when/utils.rb', line 5

def load_strategy(strategy_type, strategy)
  if strategy.is_a?(Symbol) || strategy.is_a?(String)
    require "say_when/#{strategy_type}/#{strategy}_strategy"
    class_name = "SayWhen::#{strategy_type.to_s.camelize}::#{strategy.to_s.camelize}Strategy"
    strategy_class = class_name.constantize
    strategy_class
  else
    strategy
  end
end