Class: Rutter::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/rutter/scope.rb

Overview

Scoped set of routes.

Instance Method Summary collapse

Instance Method Details

#mount(app, at:, **opts) ⇒ Object

See Also:



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

See Also:



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

See Also:



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