Class: DynamicLinks::StrategyFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamic_links/strategy_factory.rb

Class Method Summary collapse

Class Method Details

.get_strategy(strategy_name) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dynamic_links/strategy_factory.rb', line 3

def self.get_strategy(strategy_name)
  case strategy_name
  when :md5
    ShorteningStrategies::MD5Strategy.new
  when :sha256
    ShorteningStrategies::SHA256Strategy.new
  when :crc32
    ShorteningStrategies::CRC32Strategy.new
  when :nano_id
    ShorteningStrategies::NanoIdStrategy.new
  when :redis_counter
    ShorteningStrategies::RedisCounterStrategy.new
  when :mock
    ShorteningStrategies::MockStrategy.new
  else
    raise "Unknown strategy: #{strategy_name}"
  end
end