Module: Optionable
- Defined in:
- lib/optionable.rb,
lib/optionable/any.rb,
lib/optionable/dsl.rb,
lib/optionable/invalid.rb,
lib/optionable/unknown.rb,
lib/optionable/version.rb,
lib/optionable/validator.rb
Overview
This module is to be included in objects that require some nifty options validation.
Defined Under Namespace
Modules: DSL Classes: Any, Invalid, Unknown, Validator
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.any(type) ⇒ Object
Provides a convenience method for creating a new option acceptance for values of a certain type.
Instance Method Summary collapse
-
#validate_strict(options) ⇒ Object
Validate the provided options against the defined acceptable values.
Class Method Details
Instance Method Details
#validate_strict(options) ⇒ Object
Validate the provided options against the defined acceptable values.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/optionable.rb', line 26 def validate_strict() ( || {}).each_pair do |key, value| validator = optionable_validators[key] if validator validator.validate!(value) else raise Unknown.new(key, optionable_validators.keys) end end end |