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
Public Class Methods
Source
# File lib/grape/namespace.rb, line 27 def self.joined_space(settings) settings&.map(&:space) end
(see ::joined_space_path
)
Source
# File lib/grape/namespace.rb, line 33 def self.joined_space_path(settings) JoinedSpaceCache[joined_space(settings)] end
Join the namespaces from a list of settings to create a path prefix. @param settings [Array] list of Grape::Util::InheritableSettings.
Source
# File lib/grape/namespace.rb, line 15 def initialize(space, options) @space = space.to_s @options = options end
@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.
Public Instance Methods
Source
# File lib/grape/namespace.rb, line 22 def requirements options[:requirements] || {} end
Retrieves the requirements from the options hash, if given. @return [Hash]