Class: Usher::Route::Variable
- Inherits:
-
Object
- Object
- Usher::Route::Variable
- Defined in:
- lib/usher/route/variable.rb
Defined Under Namespace
Constant Summary collapse
- Greedy =
Class.new(Variable)
Instance Attribute Summary collapse
-
#default_value ⇒ Object
Returns the value of attribute default_value.
-
#look_ahead ⇒ Object
Returns the value of attribute look_ahead.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#regex_matcher ⇒ Object
readonly
Returns the value of attribute regex_matcher.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Instance Method Summary collapse
Instance Attribute Details
#default_value ⇒ Object
Returns the value of attribute default_value.
5 6 7 |
# File 'lib/usher/route/variable.rb', line 5 def default_value @default_value end |
#look_ahead ⇒ Object
Returns the value of attribute look_ahead.
5 6 7 |
# File 'lib/usher/route/variable.rb', line 5 def look_ahead @look_ahead end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/usher/route/variable.rb', line 4 def name @name end |
#regex_matcher ⇒ Object (readonly)
Returns the value of attribute regex_matcher.
4 5 6 |
# File 'lib/usher/route/variable.rb', line 4 def regex_matcher @regex_matcher end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/usher/route/variable.rb', line 4 def type @type end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
4 5 6 |
# File 'lib/usher/route/variable.rb', line 4 def validator @validator end |
Instance Method Details
#==(o) ⇒ Object
27 28 29 |
# File 'lib/usher/route/variable.rb', line 27 def ==(o) o && (o.class == self.class && o.name == @name && o.validator == @validator) end |
#valid!(val) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/usher/route/variable.rb', line 14 def valid!(val) case @validator when Proc begin @validator.call(val) rescue Exception => e raise ValidationException.new("#{val} does not conform to #{@g}, root cause #{e.inspect}") end else @validator === val or raise(ValidationException.new("#{val} does not conform to #{@validator}, root cause #{e.inspect}")) end if @validator end |