Class: Rackr::Router::Route
- Inherits:
-
Object
- Object
- Rackr::Router::Route
- Defined in:
- lib/rackr/router/route.rb
Instance Attribute Summary collapse
-
#afters ⇒ Object
readonly
Returns the value of attribute afters.
-
#befores ⇒ Object
readonly
Returns the value of attribute befores.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#has_afters ⇒ Object
readonly
Returns the value of attribute has_afters.
-
#has_befores ⇒ Object
readonly
Returns the value of attribute has_befores.
-
#has_params ⇒ Object
readonly
Returns the value of attribute has_params.
-
#splitted_path ⇒ Object
readonly
Returns the value of attribute splitted_path.
Instance Method Summary collapse
-
#initialize(path, endpoint, befores: [], afters: [], wildcard: false) ⇒ Route
constructor
A new instance of Route.
- #match?(path_info) ⇒ Boolean
Constructor Details
#initialize(path, endpoint, befores: [], afters: [], wildcard: false) ⇒ Route
Returns a new instance of Route.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rackr/router/route.rb', line 14 def initialize(path, endpoint, befores: [], afters: [], wildcard: false) @path = path @splitted_path = @path.split('/') @endpoint = endpoint @params = fetch_params @has_params = @params != [] @befores = befores @has_befores = befores != [] @afters = afters @has_afters = afters != [] @path_regex = /\A#{path.gsub(/(:\w+)/, '([^/]+)')}\z/ @wildcard = wildcard end |
Instance Attribute Details
#afters ⇒ Object (readonly)
Returns the value of attribute afters.
6 7 8 |
# File 'lib/rackr/router/route.rb', line 6 def afters @afters end |
#befores ⇒ Object (readonly)
Returns the value of attribute befores.
6 7 8 |
# File 'lib/rackr/router/route.rb', line 6 def befores @befores end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/rackr/router/route.rb', line 6 def endpoint @endpoint end |
#has_afters ⇒ Object (readonly)
Returns the value of attribute has_afters.
6 7 8 |
# File 'lib/rackr/router/route.rb', line 6 def has_afters @has_afters end |
#has_befores ⇒ Object (readonly)
Returns the value of attribute has_befores.
6 7 8 |
# File 'lib/rackr/router/route.rb', line 6 def has_befores @has_befores end |
#has_params ⇒ Object (readonly)
Returns the value of attribute has_params.
6 7 8 |
# File 'lib/rackr/router/route.rb', line 6 def has_params @has_params end |
#splitted_path ⇒ Object (readonly)
Returns the value of attribute splitted_path.
6 7 8 |
# File 'lib/rackr/router/route.rb', line 6 def splitted_path @splitted_path end |
Instance Method Details
#match?(path_info) ⇒ Boolean
28 29 30 31 32 33 |
# File 'lib/rackr/router/route.rb', line 28 def match?(path_info) return path_info.match?(@path_regex) if @has_params return true if @wildcard path_info == @path end |