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.
- .get_strategy(options) ⇒ Object
- .leaky_bucket ⇒ Object
- .validate_options!(options) ⇒ Object
Class Method Details
.build(options) ⇒ Object
Sanitizes the option set and sets defaults
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/prop/options.rb', line 8 def self.build() key = .fetch(:key) params = .fetch(:params) defaults = .fetch(:defaults) result = defaults.merge(params) result[:key] = Prop::Key.normalize(key) result[:strategy] = get_strategy(result) result[:strategy].(result) result end |
.get_strategy(options) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/prop/options.rb', line 25 def self.get_strategy() if leaky_bucket.include?([:strategy]) Prop::LeakyBucketStrategy elsif [:strategy] == nil Prop::IntervalStrategy else [:strategy] # allowing any new/unknown strategy to be used end end |
.leaky_bucket ⇒ Object
35 36 37 |
# File 'lib/prop/options.rb', line 35 def self.leaky_bucket [:leaky_bucket, "leaky_bucket"] end |
.validate_options!(options) ⇒ Object
21 22 23 |
# File 'lib/prop/options.rb', line 21 def self.() get_strategy().() end |