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
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_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

Returns:

  • (Boolean)


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

def matched?
  true
end

#partial_match?Boolean

Returns:

  • (Boolean)


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

def partial_match?
  remaining_path || route.partially_match?
end