Module: Kanpachi::APIList

Defined in:
lib/kanpachi/api_list.rb

Overview

Module to keep track of all APIs

Class Method Summary collapse

Class Method Details

.add(api) ⇒ Hash<Kanpachi::API>

Add a resource to the list

Parameters:

Returns:

Raises:

  • DuplicateAPI If a resource is being duplicated.



32
33
34
# File 'lib/kanpachi/api_list.rb', line 32

def add(api)
  @list[api.name] = api
end

.allArray<Kanpachi::API>

Returns an array of APIs

Returns:



22
23
24
# File 'lib/kanpachi/api_list.rb', line 22

def all
  @list.values
end

.clearObject

Clears all APIs



57
58
59
# File 'lib/kanpachi/api_list.rb', line 57

def clear
  @list = {}
end

.delete(name) ⇒ Object

Delete a resource to the list

Parameters:

  • The (String)

    name of the API to delete.



40
41
42
# File 'lib/kanpachi/api_list.rb', line 40

def delete(name)
  @list.delete(name)
end

.find(name) ⇒ Kanpachi::API

Returns a API based on its name

Parameters:

  • name (String)

    The name of the API you are looking for.

Returns:



50
51
52
# File 'lib/kanpachi/api_list.rb', line 50

def find(name)
  @list[name]
end

.to_hashHash<Kanpachi::API>

Returns a hash of APIs

Returns:



14
15
16
# File 'lib/kanpachi/api_list.rb', line 14

def to_hash
  @list
end