class Prop::Options
Public Class Methods
build(options)
click to toggle source
Sanitizes the option set and sets defaults
# File lib/prop/options.rb, line 8 def self.build(options) key = options.fetch(:key) 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].validate_options!(result) result end
get_strategy(options)
click to toggle source
# File lib/prop/options.rb, line 25 def self.get_strategy(options) if leaky_bucket.include?(options[:strategy]) Prop::LeakyBucketStrategy elsif options[:strategy] == nil Prop::IntervalStrategy else options[:strategy] # allowing any new/unknown strategy to be used end end
leaky_bucket()
click to toggle source
# File lib/prop/options.rb, line 35 def self.leaky_bucket [:leaky_bucket, "leaky_bucket"] end
validate_options!(options)
click to toggle source
# File lib/prop/options.rb, line 21 def self.validate_options!(options) get_strategy(options).validate_options!(options) end