Class: Sinatra::ParamValidator::Definitions
- Inherits:
-
Object
- Object
- Sinatra::ParamValidator::Definitions
- Defined in:
- lib/sinatra/param_validator/definitions.rb
Overview
Store of valid definitions
Instance Method Summary collapse
- #add(identifier, validator) ⇒ Object
- #get(identifier) ⇒ Object
-
#initialize ⇒ Definitions
constructor
A new instance of Definitions.
Constructor Details
#initialize ⇒ Definitions
Returns a new instance of Definitions.
7 8 9 |
# File 'lib/sinatra/param_validator/definitions.rb', line 7 def initialize @definitions = {} end |
Instance Method Details
#add(identifier, validator) ⇒ Object
11 12 13 14 15 |
# File 'lib/sinatra/param_validator/definitions.rb', line 11 def add(identifier, validator) raise "Validator already defined: '#{identifier}'" if @definitions.key? identifier @definitions[identifier] = validator end |
#get(identifier) ⇒ Object
17 18 19 20 21 |
# File 'lib/sinatra/param_validator/definitions.rb', line 17 def get(identifier) raise "Unknown validator: '#{identifier}'" unless @definitions.key? identifier @definitions[identifier] end |