Class: Kawaii::Matcher Abstract
- Inherits:
-
Object
- Object
- Kawaii::Matcher
- Defined in:
- lib/kawaii/matchers.rb
Overview
This class is abstract.
Base class for a route matcher.
Class Method Summary (collapse)
-
+ (Object) compile(path, options = {})
Creates a matcher.
Instance Method Summary (collapse)
-
- (Match) match(_path)
Tries to match the actual path.
Class Method Details
+ (Object) compile(path, options = {})
Creates a matcher. Generated matchers by default match only the beginning of the string containing the actual path from Rack environment.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/kawaii/matchers.rb', line 31 def self.compile(path, = {}) # @todo Make it extendable? matcher = if path.is_a?(String) StringMatcher.new(path) elsif path.is_a?(Regexp) RegexpMatcher.new(path) elsif path.is_a?(Matcher) path else fail RuntimeException, "#{path} is not a supported matcher" end [:full_match] ? FullMatcher.new(matcher) : matcher end |
Instance Method Details
- (Match) match(_path)
Tries to match the actual path. no match.
49 50 51 |
# File 'lib/kawaii/matchers.rb', line 49 def match(_path) fail NotImplementedError end |