Class: Sinatra::ParamValidator::Definitions

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/param_validator/definitions.rb

Overview

Store of valid definitions

Instance Method Summary collapse

Constructor Details

#initializeDefinitions

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