class Grape::Namespace
A container for endpoints or other namespaces, which allows for both logical grouping of endpoints as well as sharing common configuration. May also be referred to as group, segment, or resource.
Attributes
options[R]
space[R]
Public Class Methods
joined_space(settings)
click to toggle source
(see ::joined_space_path
)
# File lib/grape/namespace.rb, line 29 def self.joined_space(settings) settings&.map(&:space) end
joined_space_path(settings)
click to toggle source
Join the namespaces from a list of settings to create a path prefix. @param settings [Array] list of Grape::Util::InheritableSettings.
# File lib/grape/namespace.rb, line 35 def self.joined_space_path(settings) Grape::Router.normalize_path(JoinedSpaceCache[joined_space(settings)]) end
new(space, **options)
click to toggle source
@param space [String] the name of this namespace @param options [Hash] options hash @option options :requirements [Hash] param-regex pairs, all of which must
be met by a request's params for all endpoints in this namespace, or validation will fail and return a 422.
# File lib/grape/namespace.rb, line 17 def initialize(space, **options) @space = space.to_s @options = options end
Public Instance Methods
requirements()
click to toggle source
Retrieves the requirements from the options hash, if given. @return [Hash]
# File lib/grape/namespace.rb, line 24 def requirements options[:requirements] || {} end