lib/prop/options.rb in prop-2.3.0 vs lib/prop/options.rb in prop-2.4.0
- old
+ new
@@ -10,20 +10,27 @@
params = options.fetch(:params)
defaults = options.fetch(:defaults)
result = defaults.merge(params)
result[:key] = Prop::Key.normalize(key)
+ result[:strategy] = get_strategy(result)
- result[:strategy] = if leaky_bucket.include?(result[:strategy])
+ result[:strategy].validate_options!(result)
+ result
+ end
+
+ def self.validate_options!(options)
+ get_strategy(options).validate_options!(options)
+ end
+
+ def self.get_strategy(options)
+ if leaky_bucket.include?(options[:strategy])
Prop::LeakyBucketStrategy
- elsif result[:strategy] == nil
+ elsif options[:strategy] == nil
Prop::IntervalStrategy
else
- result[:strategy] # allowing any new/unknown strategy to be used
+ options[:strategy] # allowing any new/unknown strategy to be used
end
-
- result[:strategy].validate_options!(result)
- result
end
def self.leaky_bucket
[:leaky_bucket, "leaky_bucket"]
end