Class: Expressr::Route
- Inherits:
-
Object
- Object
- Expressr::Route
- Defined in:
- lib/expressr/route.rb
Instance Method Summary collapse
- #all(&block) ⇒ Object
- #delete(&block) ⇒ Object
- #get(&block) ⇒ Object
-
#initialize(options = {}) ⇒ Route
constructor
A new instance of Route.
- #post(&block) ⇒ Object
- #put(&block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Route
Returns a new instance of Route.
3 4 5 6 |
# File 'lib/expressr/route.rb', line 3 def initialize(={}) @router = [:router] || raise('No router provided') @path = [:path] || raise('No path provided') end |
Instance Method Details
#all(&block) ⇒ Object
8 9 10 11 |
# File 'lib/expressr/route.rb', line 8 def all(&block) @router.add_route(block, path: @path) self end |
#delete(&block) ⇒ Object
28 29 30 31 |
# File 'lib/expressr/route.rb', line 28 def delete(&block) @router.delete(@path, &block) self end |
#get(&block) ⇒ Object
13 14 15 16 |
# File 'lib/expressr/route.rb', line 13 def get(&block) @router.get(@path, &block) self end |
#post(&block) ⇒ Object
23 24 25 26 |
# File 'lib/expressr/route.rb', line 23 def post(&block) @router.post(@path, &block) self end |
#put(&block) ⇒ Object
18 19 20 21 |
# File 'lib/expressr/route.rb', line 18 def put(&block) @router.put(@path, &block) self end |