Class: Rutter::Scope
- Inherits:
-
Object
- Object
- Rutter::Scope
- Defined in:
- lib/rutter/scope.rb
Overview
Scoped set of routes.
Instance Method Summary collapse
Instance Method Details
#mount(app, at:, **opts) ⇒ Object
44 45 46 47 |
# File 'lib/rutter/scope.rb', line 44 def mount(app, at:, **opts) at = "#{@path_prefix}/#{at}" if @path_prefix @router.mount app, at: at, **opts end |
#root(to:, as: :root) ⇒ Object
50 51 52 |
# File 'lib/rutter/scope.rb', line 50 def root(to:, as: :root) get "/", to: to, as: as end |
#scope(**opts, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rutter/scope.rb', line 32 def scope(**opts, &block) opts[:as] = "#{@name_prefix}_#{opts[:as]}" if @name_prefix opts[:path] = "#{@path_prefix}/#{opts[:path]}" if @path_prefix if @namespace_prefix opts[:namespace] = "#{@namespace_prefix}::#{opts[:namespace]}" end Scope.new(@router, **opts, &block) end |