Class: HttpRouter::Response::Matched
- Inherits:
-
Struct
- Object
- Struct
- HttpRouter::Response::Matched
- Defined in:
- lib/http_router/response.rb
Instance Attribute Summary collapse
-
#params_as_hash ⇒ Object
readonly
Returns the value of attribute params_as_hash.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
Instance Method Summary collapse
- #dest ⇒ Object (also: #destination)
-
#initialize(path, params, matched_path, remaining_path = nil) ⇒ Matched
constructor
A new instance of Matched.
- #matched? ⇒ Boolean
- #partial_match? ⇒ Boolean
Constructor Details
#initialize(path, params, matched_path, remaining_path = nil) ⇒ Matched
Returns a new instance of Matched.
21 22 23 24 25 26 |
# File 'lib/http_router/response.rb', line 21 def initialize(path, params, matched_path, remaining_path = nil) raise if matched_path.nil? super path.splitting_indexes and path.splitting_indexes.each{|i| params[i] = params[i].split('/')} @params_as_hash = path.variable_names.zip(params).inject({}) {|h, (k,v)| h[k] = v; h } end |
Instance Attribute Details
#params_as_hash ⇒ Object (readonly)
Returns the value of attribute params_as_hash.
19 20 21 |
# File 'lib/http_router/response.rb', line 19 def params_as_hash @params_as_hash end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
19 20 21 |
# File 'lib/http_router/response.rb', line 19 def route @route end |
Instance Method Details
#dest ⇒ Object Also known as: destination
36 37 38 |
# File 'lib/http_router/response.rb', line 36 def dest route.dest end |
#matched? ⇒ Boolean
28 29 30 |
# File 'lib/http_router/response.rb', line 28 def matched? true end |
#partial_match? ⇒ Boolean
41 42 43 |
# File 'lib/http_router/response.rb', line 41 def partial_match? remaining_path || route.partially_match? end |