Class: Restspec::Stores::NamespaceStoreDelegator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/restspec/stores/namespace_store.rb

Overview

Provides methods for the NamespaceStore object.

Instance Method Summary collapse

Instance Method Details

#get(namespace_name) ⇒ Restspec::Endpoints::Namespace?

Get a namespace by name. It gets the name as string or symbol.

Parameters:

  • namespace_name (String, Symbol)

    the namespace's name to use for search.

Returns:



23
24
25
# File 'lib/restspec/stores/namespace_store.rb', line 23

def get(namespace_name)
  fetch(namespace_name.to_s) { fetch(namespace_name.to_sym, nil) }
end

#store(namespace) ⇒ Object

Stores the namespace. It uses the namespace's name as the hash key.

Parameters:

Raises:

  • (StandardError)

    if the namespace is an anonymous one.



11
12
13
14
15
16
17
# File 'lib/restspec/stores/namespace_store.rb', line 11

def store(namespace)
  if namespace.anonymous?
    raise "Can't add an anonymous namespace to the NamespaceStore"
  else
    self[namespace.name] = namespace
  end
end