Class: Aikido::Zen::Route
- Inherits:
-
Object
- Object
- Aikido::Zen::Route
- Defined in:
- lib/aikido/zen/route.rb
Overview
Routes keep information about the mapping defined in the current web framework to go from a given HTTP request to the code that handles said request.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
The URL pattern used to match request paths.
-
#verb ⇒ String
readonly
The HTTP verb used to request this route.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #as_json ⇒ Object
- #hash ⇒ Object
-
#initialize(verb:, path:) ⇒ Route
constructor
A new instance of Route.
- #inspect ⇒ Object
Constructor Details
#initialize(verb:, path:) ⇒ Route
Returns a new instance of Route.
15 16 17 18 |
# File 'lib/aikido/zen/route.rb', line 15 def initialize(verb:, path:) @verb = verb @path = path end |
Instance Attribute Details
#path ⇒ String (readonly)
Returns the URL pattern used to match request paths. For example “/users/:id”.
13 14 15 |
# File 'lib/aikido/zen/route.rb', line 13 def path @path end |
#verb ⇒ String (readonly)
Returns the HTTP verb used to request this route.
9 10 11 |
# File 'lib/aikido/zen/route.rb', line 9 def verb @verb end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
24 25 26 27 28 |
# File 'lib/aikido/zen/route.rb', line 24 def ==(other) other.is_a?(Route) && other.verb == verb && other.path == path end |
#as_json ⇒ Object
20 21 22 |
# File 'lib/aikido/zen/route.rb', line 20 def as_json {method: verb, path: path} end |
#hash ⇒ Object
31 32 33 |
# File 'lib/aikido/zen/route.rb', line 31 def hash [verb, path].hash end |
#inspect ⇒ Object
35 36 37 |
# File 'lib/aikido/zen/route.rb', line 35 def inspect "#<#{self.class.name} #{verb} #{path.inspect}>" end |