Method: Grape::DSL::Routing::ClassMethods#namespace
- Defined in:
- lib/grape/dsl/routing.rb
#namespace(space = nil, options = {}, &block) ⇒ Object Also known as: group, resource, resources, segment
Declare a “namespace”, which prefixes all subordinate routes with its name. Any endpoints within a namespace, group, resource or segment, etc., will share their parent context as well as any configuration done in the namespace context.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/grape/dsl/routing.rb', line 177 def namespace(space = nil, = {}, &block) @namespace_description = nil unless instance_variable_defined?(:@namespace_description) && @namespace_description if space || block within_namespace do previous_namespace_description = @namespace_description @namespace_description = (@namespace_description || {}).deep_merge(namespace_setting(:description) || {}) nest(block) do namespace_stackable(:namespace, Namespace.new(space, **)) if space end @namespace_description = previous_namespace_description end else Namespace.joined_space_path(namespace_stackable(:namespace)) end end |