Class: Grape::Namespace
- Inherits:
-
Object
- Object
- Grape::Namespace
- Defined in:
- lib/grape/namespace.rb
Overview
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.
Defined Under Namespace
Classes: JoinedSpaceCache
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#space ⇒ Object
readonly
Returns the value of attribute space.
Class Method Summary collapse
- .joined_space(settings) ⇒ Object
-
.joined_space_path(settings) ⇒ Object
Join the namespaces from a list of settings to create a path prefix.
Instance Method Summary collapse
-
#initialize(space, **options) ⇒ Namespace
constructor
A new instance of Namespace.
-
#requirements ⇒ Hash
Retrieves the requirements from the options hash, if given.
Constructor Details
#initialize(space, **options) ⇒ Namespace
Returns a new instance of Namespace.
17 18 19 20 |
# File 'lib/grape/namespace.rb', line 17 def initialize(space, **) @space = space.to_s @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/grape/namespace.rb', line 10 def @options end |
#space ⇒ Object (readonly)
Returns the value of attribute space.
10 11 12 |
# File 'lib/grape/namespace.rb', line 10 def space @space end |
Class Method Details
.joined_space(settings) ⇒ Object
29 30 31 |
# File 'lib/grape/namespace.rb', line 29 def self.joined_space(settings) settings&.map(&:space) end |
.joined_space_path(settings) ⇒ Object
Join the namespaces from a list of settings to create a path prefix.
35 36 37 |
# File 'lib/grape/namespace.rb', line 35 def self.joined_space_path(settings) Grape::Router.normalize_path(JoinedSpaceCache[joined_space(settings)]) end |
Instance Method Details
#requirements ⇒ Hash
Retrieves the requirements from the options hash, if given.
24 25 26 |
# File 'lib/grape/namespace.rb', line 24 def requirements [:requirements] || {} end |