Class: Sidewalk::UriMatch

Inherits:
Object
  • Object
show all
Defined in:
lib/sidewalk/uri_match.rb

Overview

Information on a URI => Controller match.

These are generated by UriMapper.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parts = [], parameters = {}, controller = nil) ⇒ UriMatch

Returns a new instance of UriMatch.



20
21
22
23
24
25
26
27
# File 'lib/sidewalk/uri_match.rb', line 20

def initialize parts = [], parameters = {}, controller = nil
  unless parts.is_a?(Array) && parameters.is_a?(Hash)
    raise ArgumentError.new(
      'Sidewalk::UriMatch([parts], {parameters}, controller)'
    )
  end
  @parts, @parameters, @controller = parts, parameters, controller
end

Instance Attribute Details

#controllerObject (readonly)

What the URL maps to.

This should be an instance of Controller, or a Proc.



18
19
20
# File 'lib/sidewalk/uri_match.rb', line 18

def controller
  @controller
end

#parametersObject (readonly)

Any named captures from the match.



13
14
15
# File 'lib/sidewalk/uri_match.rb', line 13

def parameters
  @parameters
end

#partsObject (readonly)

The URL path, divided into regexp-matches.

The URI map is a tree; this tells you what was matched at each level of the tree.



10
11
12
# File 'lib/sidewalk/uri_match.rb', line 10

def parts
  @parts
end