Class: Rage::Router::DSL::Handler
- Inherits:
-
Object
- Object
- Rage::Router::DSL::Handler
- Defined in:
- lib/rage/router/dsl.rb
Instance Method Summary collapse
-
#delete(path, to:, constraints: nil) ⇒ Object
Register a new DELETE route.
-
#get(path, to:, constraints: nil) ⇒ Object
Register a new GET route.
-
#patch(path, to:, constraints: nil) ⇒ Object
Register a new PATCH route.
-
#post(path, to:, constraints: nil) ⇒ Object
Register a new POST route.
-
#put(path, to:, constraints: nil) ⇒ Object
Register a new PUT route.
-
#root(to:) ⇒ Object
Register a new route pointing to '/'.
-
#scope(opts, &block) ⇒ Object
Scopes a set of routes to the given default options.
Instance Method Details
#delete(path, to:, constraints: nil) ⇒ Object
Register a new DELETE route.
72 73 74 |
# File 'lib/rage/router/dsl.rb', line 72 def delete(path, to:, constraints: nil) __on("DELETE", path, to, constraints) end |
#get(path, to:, constraints: nil) ⇒ Object
Register a new GET route.
28 29 30 |
# File 'lib/rage/router/dsl.rb', line 28 def get(path, to:, constraints: nil) __on("GET", path, to, constraints) end |
#patch(path, to:, constraints: nil) ⇒ Object
Register a new PATCH route.
61 62 63 |
# File 'lib/rage/router/dsl.rb', line 61 def patch(path, to:, constraints: nil) __on("PATCH", path, to, constraints) end |
#post(path, to:, constraints: nil) ⇒ Object
Register a new POST route.
39 40 41 |
# File 'lib/rage/router/dsl.rb', line 39 def post(path, to:, constraints: nil) __on("POST", path, to, constraints) end |
#put(path, to:, constraints: nil) ⇒ Object
Register a new PUT route.
50 51 52 |
# File 'lib/rage/router/dsl.rb', line 50 def put(path, to:, constraints: nil) __on("PUT", path, to, constraints) end |
#root(to:) ⇒ Object
Register a new route pointing to '/'.
81 82 83 |
# File 'lib/rage/router/dsl.rb', line 81 def root(to:) __on("GET", "/", to, nil) end |
#scope(opts, &block) ⇒ Object
Scopes a set of routes to the given default options.
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/rage/router/dsl.rb', line 106 def scope(opts, &block) raise ArgumentError, "only 'module' and 'path' options are accepted" if (opts.keys - %i(module path)).any? @path_prefixes << opts[:path].delete_prefix("/").delete_suffix("/") if opts[:path] @module_prefixes << opts[:module] if opts[:module] instance_eval &block @path_prefixes.pop if opts[:path] @module_prefixes.pop if opts[:module] end |