Class: Prop::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/prop/options.rb

Class Method Summary collapse

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
20
21
22
23
24
25
26
# 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] = 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].validate_options!(result)
  result
end

.leaky_bucketObject



28
29
30
# File 'lib/prop/options.rb', line 28

def self.leaky_bucket
  [:leaky_bucket, "leaky_bucket"]
end