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, matched_path, remaining_path = nil) ⇒ Matched

Returns a new instance of Matched.



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

def initialize(path, params, matched_path, remaining_path = nil)
  raise if matched_path.nil?
  super
  @params_as_hash = path.variable_names.zip(params).inject({}) {|h, (k,v)| h[k] = v; h }
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



35
36
37
# File 'lib/http_router/response.rb', line 35

def dest
  route.dest
end

#matched?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/http_router/response.rb', line 27

def matched?
  true
end

#partial_match?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/http_router/response.rb', line 40

def partial_match?
  remaining_path
end