Sha256: e60acff5bfb39da393b89689720438579b8402916315e76573678a9792a7b157

Contents?: true

Size: 647 Bytes

Versions: 13

Compression:

Stored size: 647 Bytes

Contents

require 'prop/key'

module Prop
  class Options

    # Sanitizes the option set and sets defaults
    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[:threshold] = result[:threshold].to_i
      result[:interval]  = result[:interval].to_i

      raise RuntimeError.new("Invalid threshold setting") unless result[:threshold] > 0
      raise RuntimeError.new("Invalid interval setting")  unless result[:interval] > 0

      result
    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
prop-1.1.0 lib/prop/options.rb
prop-1.0.2 lib/prop/options.rb
prop-1.0.1 lib/prop/options.rb
prop-1.0.0 lib/prop/options.rb
prop-0.7.8 lib/prop/options.rb
prop-0.7.7 lib/prop/options.rb
prop-0.7.6 lib/prop/options.rb
prop-0.7.5 lib/prop/options.rb
prop-0.7.4 lib/prop/options.rb
prop-0.7.3 lib/prop/options.rb
prop-0.7.2 lib/prop/options.rb
prop-0.7.1 lib/prop/options.rb
prop-0.7.0 lib/prop/options.rb