Class: HttpRouter::Response::Matched

Inherits:
Struct
  • Object
show all
Defined in:
lib/http_router/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, params, extension, matched_path, remaining_path) ⇒ Matched



21
22
23
24
25
26
# File 'lib/http_router/response.rb', line 21

def initialize(path, params, extension, matched_path, remaining_path)
  raise if matched_path.nil?
  super
  @params_as_hash = path.variable_names.zip(params).inject({}) {|h, (k,v)| h[k] = v; h }
  @params_as_hash[path.extension.name] = extension if path.extension && path.extension.is_a?(Variable)
end

Instance Attribute Details

#params_as_hashObject (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

#routeObject (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

#destObject 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
end