Class: HttpRouter::Node::Arbitrary
- Inherits:
-
HttpRouter::Node
- Object
- HttpRouter::Node
- HttpRouter::Node::Arbitrary
- Defined in:
- lib/http_router/node/arbitrary.rb
Instance Attribute Summary
Attributes inherited from HttpRouter::Node
Instance Method Summary collapse
- #[](request) ⇒ Object
-
#initialize(router, allow_partial, blk, param_names) ⇒ Arbitrary
constructor
A new instance of Arbitrary.
Methods inherited from HttpRouter::Node
#add_arbitrary, #add_destination, #add_free_match, #add_glob, #add_lookup, #add_match, #add_request, #add_spanning_match, #add_variable, #arbitrary, #destination, #glob, #join_whole_path, #linear, #lookup, #request, #unescape, #variable
Constructor Details
#initialize(router, allow_partial, blk, param_names) ⇒ Arbitrary
Returns a new instance of Arbitrary.
4 5 6 |
# File 'lib/http_router/node/arbitrary.rb', line 4 def initialize(router, allow_partial, blk, param_names) @router, @allow_partial, @blk, @param_names = router, allow_partial, blk, param_names end |
Instance Method Details
#[](request) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/http_router/node/arbitrary.rb', line 8 def [](request) if request.path.empty? or (request.path.size == 1 and request.path[0] == '') or @allow_partial request = request.clone request.continue = proc { |state| destination(request) if state } params = @param_names.nil? ? {} : Hash[@param_names.zip(request.params)] @blk.call(request, params) end end |