class Threatinator::Registry

Just a simple class that holds stuff. Yup, a glorified hash.

Public Class Methods

new() click to toggle source
# File lib/threatinator/registry.rb, line 8
def initialize()
  @data= Hash.new
end

Public Instance Methods

clear() click to toggle source

Removes all objects from the registry

# File lib/threatinator/registry.rb, line 48
def clear
  @data.clear
end
count() click to toggle source

@return [Integer] the number of objects in the registry

# File lib/threatinator/registry.rb, line 35
def count
  @data.count
end
each(&block) click to toggle source

Enumerates through each object in our registry @yield [object] @yieldparam [Object] object An object within the registry

# File lib/threatinator/registry.rb, line 42
def each(&block)
  return enum_for(:each) unless block_given?
  @data.each_pair(&block)
end
get(key) click to toggle source

@param [Object] key @return [Object]

# File lib/threatinator/registry.rb, line 25
def get(key)
  @data[key]
end
keys() click to toggle source

@return [Array<Object>] an array of keys

# File lib/threatinator/registry.rb, line 30
def keys
  @data.keys
end
register(key, object) click to toggle source

@param [Object] key The object to use as the key for storing the object @param [Object] object The object to be stored @raise [Threatinator::Exceptions::dAlreadyRegisteredError] if an object

with the same key is already registered.
# File lib/threatinator/registry.rb, line 16
def register(key, object)
  if @data.has_key?(key)
    raise AlreadyRegisteredError.new(key)
  end
  @data[key] = object
end