Class: Kawaii::RouteContext
- Inherits:
-
Object
- Object
- Kawaii::RouteContext
- Includes:
- MethodChain, RoutingMethods
- Defined in:
- lib/kawaii/route_context.rb
Overview
Implementation of nested routes generated via Router#context.
Instance Attribute Summary
Attributes included from MethodChain
Instance Method Summary (collapse)
-
- (RouteContext) initialize(scope, path)
constructor
Create a RouteContext object.
-
- (Route) match(env)
Tries to match the context against a Rack environment.
Methods included from MethodChain
Methods included from RoutingMethods
add_http_method, #context, #delete, #get, #head, #link, #methods_used, #options, #patch, #post, #put, #route, #trace, #unlink
Constructor Details
- (RouteContext) initialize(scope, path)
Create a Kawaii::RouteContext object. be consumed by Matcher.compile
24 25 26 27 28 |
# File 'lib/kawaii/route_context.rb', line 24 def initialize(scope, path) self.parent_scope = scope super() @matcher = Matcher.compile(path, starts_with: true) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Kawaii::MethodChain
Instance Method Details
- (Route) match(env)
Tries to match the context against a Rack environment. no match found.
34 35 36 37 |
# File 'lib/kawaii/route_context.rb', line 34 def match(env) m = @matcher.match(env[Rack::PATH_INFO]) super(env.merge(Rack::PATH_INFO => ensure_slash(m.remaining_path))) if m end |