Module: Agent::Lock::Facade::Strategies
- Defined in:
- lib/agent/lock/facade/strategies.rb
Overview
Turns the strategies: a caller passed into the backend names a
Backend tries, in order.
Constant Summary collapse
- FILE_ALIASES =
Names that mean the file store.
%w[file filesystem].freeze
Class Method Summary collapse
-
.canonical(name) ⇒ String
"redis" or "file".
-
.parse(strategies) ⇒ Array<String>
"redis" and "file", in the order given, without repeats.
Class Method Details
.canonical(name) ⇒ String
Returns "redis" or "file".
27 28 29 30 31 32 |
# File 'lib/agent/lock/facade/strategies.rb', line 27 def canonical(name) return "file" if FILE_ALIASES.include?(name) return name if name == "redis" raise ArgumentError, "unknown strategy #{name.inspect}, expected redis or file" end |
.parse(strategies) ⇒ Array<String>
Returns "redis" and "file", in the order given, without repeats.
17 18 19 20 21 22 |
# File 'lib/agent/lock/facade/strategies.rb', line 17 def parse(strategies) names = Array(strategies).map { |name| canonical(name.to_s.strip.downcase) }.uniq raise ArgumentError, "strategies must name at least one of redis, file" if names.empty? names end |