Class: Grape::Namespace

Inherits:
Object show all
Defined in:
lib/grape/namespace.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(space, options = {}) ⇒ Namespace

options: requirements: a hash



7
8
9
10
# File 'lib/grape/namespace.rb', line 7

def initialize(space, options = {})
  @space = space.to_s
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/grape/namespace.rb', line 3

def options
  @options
end

#spaceObject (readonly)

Returns the value of attribute space.



3
4
5
# File 'lib/grape/namespace.rb', line 3

def space
  @space
end

Class Method Details

.joined_space(settings) ⇒ Object



16
17
18
# File 'lib/grape/namespace.rb', line 16

def self.joined_space(settings)
  (settings || []).map(&:space).join('/')
end

.joined_space_path(settings) ⇒ Object



20
21
22
# File 'lib/grape/namespace.rb', line 20

def self.joined_space_path(settings)
  Rack::Mount::Utils.normalize_path(joined_space(settings))
end

Instance Method Details

#requirementsObject



12
13
14
# File 'lib/grape/namespace.rb', line 12

def requirements
  options[:requirements] || {}
end