Class: PPT::Presenters::Validator
- Inherits:
-
Object
- Object
- PPT::Presenters::Validator
- Defined in:
- lib/simple-orm/presenters.rb
Instance Method Summary collapse
-
#initialize(message, &block) ⇒ Validator
constructor
A new instance of Validator.
- #validate!(name, value) ⇒ Object
Constructor Details
#initialize(message, &block) ⇒ Validator
Returns a new instance of Validator.
10 11 12 |
# File 'lib/simple-orm/presenters.rb', line 10 def initialize(, &block) @message, @block = , block end |
Instance Method Details
#validate!(name, value) ⇒ Object
14 15 16 17 18 |
# File 'lib/simple-orm/presenters.rb', line 14 def validate!(name, value) unless @block.call(value) raise ValidationError.new("Value of #{name} is invalid (value is #{value.inspect}).") end end |