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.
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 |
# 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[: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 |