Class: Prop::Options
- Inherits:
-
Object
- Object
- Prop::Options
- Defined in:
- lib/prop/options.rb
Class Method Summary collapse
-
.build(options) ⇒ Object
Sanitizes the option set and sets defaults.
- .leaky_bucket ⇒ Object
Class Method Details
.build(options) ⇒ Object
Sanitizes the option set and sets defaults
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/prop/options.rb', line 7 def self.build() key = .fetch(:key) params = .fetch(:params) defaults = .fetch(:defaults) result = defaults.merge(params) result[:key] = Prop::Key.normalize(key) result[:strategy] = if leaky_bucket.include?(result[:strategy]) Prop::LeakyBucketStrategy elsif result[:strategy] == nil Prop::IntervalStrategy else result[:strategy] # allowing any new/unknown strategy to be used end result[:strategy].(result) result end |
.leaky_bucket ⇒ Object
27 28 29 |
# File 'lib/prop/options.rb', line 27 def self.leaky_bucket [:leaky_bucket, "leaky_bucket"] end |