Class: Rack::HttpRouter::Router::Route
- Inherits:
-
Object
- Object
- Rack::HttpRouter::Router::Route
- Defined in:
- lib/rack-http_router/router/route.rb
Instance Attribute Summary collapse
-
#befores ⇒ Object
readonly
Returns the value of attribute befores.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#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 = []) ⇒ Route
constructor
A new instance of Route.
- #match?(env) ⇒ Boolean
Constructor Details
#initialize(path, endpoint, befores = []) ⇒ Route
Returns a new instance of Route.
9 10 11 12 13 14 15 16 17 |
# File 'lib/rack-http_router/router/route.rb', line 9 def initialize(path, endpoint, befores = []) @path = path @splitted_path = @path.split('/') @endpoint = endpoint @params = fetch_params @has_params = @params != [] @befores = befores @has_befores = befores != [] end |
Instance Attribute Details
#befores ⇒ Object (readonly)
Returns the value of attribute befores.
7 8 9 |
# File 'lib/rack-http_router/router/route.rb', line 7 def befores @befores end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
7 8 9 |
# File 'lib/rack-http_router/router/route.rb', line 7 def endpoint @endpoint end |
#has_befores ⇒ Object (readonly)
Returns the value of attribute has_befores.
7 8 9 |
# File 'lib/rack-http_router/router/route.rb', line 7 def has_befores @has_befores end |
#has_params ⇒ Object (readonly)
Returns the value of attribute has_params.
7 8 9 |
# File 'lib/rack-http_router/router/route.rb', line 7 def has_params @has_params end |
#splitted_path ⇒ Object (readonly)
Returns the value of attribute splitted_path.
7 8 9 |
# File 'lib/rack-http_router/router/route.rb', line 7 def splitted_path @splitted_path end |
Instance Method Details
#match?(env) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/rack-http_router/router/route.rb', line 19 def match?(env) return match_with_params?(env) if @has_params env['REQUEST_PATH'] == @path end |