Sha256: d2c382062c31777461b10d55afec9dc106c9481e7bb0837cb13baf7f09e9a3c7
Contents?: true
Size: 1.15 KB
Versions: 13
Compression:
Stored size: 1.15 KB
Contents
class Usher class Route class Variable attr_reader :type, :name, :validator, :regex_matcher attr_accessor :look_ahead, :default_value def initialize(name, regex_matcher = nil, validator = nil) @name = name.to_s.to_sym @validator = validator @regex_matcher = regex_matcher end private :initialize 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 def ==(o) o && (o.class == self.class && o.name == @name && o.validator == @validator) end class Single < Variable def to_s ":#{name}" end end class Glob < Variable def to_s "*#{name}" end end Greedy = Class.new(Variable) end end end
Version data entries
13 entries across 13 versions & 2 rubygems