Class: Rack::Parameter::Rule
- Inherits:
-
Object
- Object
- Rack::Parameter::Rule
- Defined in:
- lib/rack/param.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, &block) ⇒ Rule
constructor
A new instance of Rule.
- #validate(param, value, error_msg = nil) ⇒ Object
Constructor Details
#initialize(message, &block) ⇒ Rule
Returns a new instance of Rule.
49 50 51 52 |
# File 'lib/rack/param.rb', line 49 def initialize , &block @block = block = end |
Class Method Details
.rule(message, &block) ⇒ Object
54 55 56 |
# File 'lib/rack/param.rb', line 54 def self.rule , &block new , &block end |
Instance Method Details
#validate(param, value, error_msg = nil) ⇒ Object
58 59 60 |
# File 'lib/rack/param.rb', line 58 def validate param, value, error_msg=nil return (error_msg || ).sub('$',"`#{param.to_s}`").sub('#',"`#{value.to_s}`") unless @block.call(param,value) end |