Class: Sinatra::Browse::Validator
- Inherits:
-
Object
- Object
- Sinatra::Browse::Validator
- Defined in:
- lib/sinatra/browse/validator.rb
Instance Attribute Summary collapse
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(map) ⇒ Validator
constructor
A new instance of Validator.
- #validate(param_name, params) ⇒ Object
Constructor Details
#initialize(map) ⇒ Validator
Returns a new instance of Validator.
9 10 11 12 13 |
# File 'lib/sinatra/browse/validator.rb', line 9 def initialize(map) @name = map[:name] @criteria = map[:criteria] @validation_blk = map[:validation_blk] end |
Instance Attribute Details
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
5 6 7 |
# File 'lib/sinatra/browse/validator.rb', line 5 def criteria @criteria end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/sinatra/browse/validator.rb', line 7 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/sinatra/browse/validator.rb', line 6 def value @value end |
Instance Method Details
#validate(param_name, params) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/sinatra/browse/validator.rb', line 15 def validate(param_name, params) @value = params[param_name] @params = params instance_exec @criteria, &@validation_blk end |