class OEHClient::Config::SpaceManager

Attributes

spaces[RW]

Public Class Methods

new() click to toggle source

Constructor. Initialize the spaces collection as a new hash

# File lib/oehclient/config/space_manager.rb, line 10
def initialize
        @spaces       = Hash.new
end

Public Instance Methods

get(site_key) click to toggle source

get_space returns the instance of the OEHClient::Config::Space

# File lib/oehclient/config/space_manager.rb, line 24
def get(site_key)

        # raise the OEHClient::Exception::InvalidSpaceException if the space has not been registered
        raise OEHClient::Exception::InvalidSpaceException unless (@spaces.has_key?(site_key))

        # return the space configuration instance
        @spaces[site_key]

end
register_space(space_config={}) click to toggle source

register_space is a wrapper method that converts the passed Hash object to an instance of the

OEHClient::Config::Space object, which is passed to the register method
# File lib/oehclient/config/space_manager.rb, line 16
def register_space(space_config={})

        # Pass a new instance of the space object to the register_space method
        register(OEHClient::Config::Space.create(space_config))

end

Private Instance Methods

register(space_instance) click to toggle source

register adds the instance of the OEHClient::Config::Space object to the spaces hash, using the

site_key value as the hash KEY
# File lib/oehclient/config/space_manager.rb, line 38
def register(space_instance)

        # Raise OEHClient::Exception::InvalidSpaceException if the space instance is NOT valie
        raise OEHClient::Exception::InvalidSpaceConfigException unless (space_instance.is_valid?)
        # Raise the OEHClient::Exception::InvalidSpaceObjectException if the space_instance object is not
        #  the proper type of object (OEHClient::Config::Space)
        raise OEHClient::Exception::InvalidSpaceObjectException unless (space_instance.kind_of?(OEHClient::Config::Space))

        # Assign the space instance to the spaces collection
        @spaces[space_instance.site_key] = space_instance 

end