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
# File 'lib/grape/namespace.rb', line 7

def initialize(space, options = {})
  @space, @options = space.to_s, 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



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

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

.joined_space_path(settings) ⇒ Object



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

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

Instance Method Details

#requirementsObject



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

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