Class: Dependo::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/dependo.rb

Overview

Where dependencies are specified (or registered), and stored for future use

Constant Summary collapse

@@attributes =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

The Registry cannot be instantiated, so this constructor just fails



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

def initialize
    raise "Cannot instantiate Dependo::Registry"
end

Class Method Details

.[](key) ⇒ Object

Returns the dependency registered with the given name.

Parameters:

  • key (symbol)

    the name of the registered dependency

Returns:

  • the dependency registered with the given name



23
24
25
# File 'lib/dependo.rb', line 23

def self.[](key)
    @@attributes[key]
end

.[]=(key, value) ⇒ Object

Parameters:

  • key (symbol)

    the name of the dependency to register

  • value (Object)

    the dependency to register



17
18
19
# File 'lib/dependo.rb', line 17

def self.[]=(key, value)
    @@attributes[key] = value
end

.clearObject

Remove all dependencies from the registry



34
35
36
# File 'lib/dependo.rb', line 34

def self.clear
    @@attributes.clear
end

.has_key?(key) ⇒ Boolean

Returns true if the name is registered, false otherwise.

Parameters:

  • key (symbol)

    the name of the registered dependency

Returns:

  • (Boolean)

    true if the name is registered, false otherwise



29
30
31
# File 'lib/dependo.rb', line 29

def self.has_key?(key)
    @@attributes.has_key?(key)
end