Method: Jets::Router::Dsl#scope

Defined in:
lib/jets/router/dsl.rb

#scope(args) ⇒ Object

scope supports three options: module, prefix and as. Jets vs Rails:

module - module
prefix - path
as - as


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jets/router/dsl.rb', line 25

def scope(args)
  # normalizes `scope(:admin)` as `scope(prefix: :admin)`
  options = case args
  when Hash
    args
  when String, Symbol
    { prefix: args }
  end

  root_level = @scope.nil?
  @scope = root_level ? Scope.new(options) : @scope.new(options)
  yield
ensure
  @scope = @scope.parent if @scope
end