Method: Jets::Router::Dsl#scope

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

#scope(*args) ⇒ Object

Examples

scope :admin
scope path: :admin
scope 'admin', as: 'admin'


82
83
84
85
86
87
88
89
90
91
92
# File 'lib/jets/router/dsl.rb', line 82

def scope(*args)
  options = args.extract_options!
  path = args.first
  options[:path] = path.to_s if path

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