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.
-
#requirements ⇒ Object
readonly
Returns the value of attribute requirements.
-
#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
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(space, requirements: nil, **options) ⇒ Namespace
constructor
A new instance of Namespace.
Constructor Details
#initialize(space, requirements: nil, **options) ⇒ Namespace
Returns a new instance of Namespace.
15 16 17 18 19 |
# File 'lib/grape/namespace.rb', line 15 def initialize(space, requirements: nil, **) @space = space.to_s @requirements = requirements @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/grape/namespace.rb', line 8 def @options end |
#requirements ⇒ Object (readonly)
Returns the value of attribute requirements.
8 9 10 |
# File 'lib/grape/namespace.rb', line 8 def requirements @requirements end |
#space ⇒ Object (readonly)
Returns the value of attribute space.
8 9 10 |
# File 'lib/grape/namespace.rb', line 8 def space @space end |
Class Method Details
.joined_space(settings) ⇒ Object
22 23 24 |
# File 'lib/grape/namespace.rb', line 22 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.
40 41 42 |
# File 'lib/grape/namespace.rb', line 40 def self.joined_space_path(settings) JoinedSpaceCache[joined_space(settings)] end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
26 27 28 29 30 31 |
# File 'lib/grape/namespace.rb', line 26 def eql?(other) other.class == self.class && other.space == space && other.requirements == requirements && other. == end |
#hash ⇒ Object
34 35 36 |
# File 'lib/grape/namespace.rb', line 34 def hash [self.class, space, requirements, ].hash end |