Class: Rasti::Web::Route
- Inherits:
-
Object
- Object
- Rasti::Web::Route
- Defined in:
- lib/rasti/web/route.rb
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #extract_params(path) ⇒ Object
-
#initialize(pattern, endpoint = nil, &block) ⇒ Route
constructor
A new instance of Route.
- #match?(path) ⇒ Boolean
Constructor Details
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
5 6 7 |
# File 'lib/rasti/web/route.rb', line 5 def pattern @pattern end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 |
# File 'lib/rasti/web/route.rb', line 22 def call(env) @endpoint.call env end |
#extract_params(path) ⇒ Object
17 18 19 20 |
# File 'lib/rasti/web/route.rb', line 17 def extract_params(path) result = @regexp.match normalize(path) result ? result.names.each_with_object(Hash::Indifferent.new) { |v,h| h[v] = result[v] } : {} end |
#match?(path) ⇒ Boolean
13 14 15 |
# File 'lib/rasti/web/route.rb', line 13 def match?(path) !@regexp.match(normalize(path)).nil? end |