Google

"DTD/xhtml1-strict.dtd">
Class Irc::BotRegistryAccessor
In: rbot/registry.rb
Parent: Object
Class: JoinMessage Class: PartMessage Class: Plugins Class: KickMessage Class: IrcAuth Class: IRCChannel Class: IrcSocket Class: BotConfig Class: Keywords Class: BotRegistryAccessor Class: IrcClient Class: DBHash Class: Language Class: TopicMessage Class: QuitMessage Class: PrivMessage Class: UserMessage Class: NoticeMessage Class: IrcBot Class: BasicUserMessage Class: NickMessage Class: Plugin Class: BotRegistry Class: Keyword Class: DBTree Module: Irc

If you don't need to store objects, and strictly want a persistant hash of strings, you can override the store/restore methods to suit your needs, for example (in your plugin):

  def initialize
    class << @registry
      def store(val)
        val
      end
      def restore(val)
        val
      end
    end
  end

Your plugins section of the registry is private, it has its own namespace (derived from the plugin's class name, so change it and lose your data). Calls to registry.each etc, will only iterate over your namespace.

Methods
[]    []=    clear    delete    each    each_key    each_value    flush    has_both?    has_key?    has_value?    index    keys    length    new    restore    set_default    store    sub_registry    to_a    to_hash    values   
Public Class methods
new(bot, prefix)

plugins don't call this - a BotRegistryAccessor is created for them and is accessible via @registry.

Public Instance methods
sub_registry(prefix)

use this to chop up your namespace into bits, so you can keep and reference separate object stores under the same registry

store(val)

convert value to string form for storing in the registry defaults to Marshal.dump(val) but you can override this in your module's registry object to use any method you like. For example, if you always just handle strings use:

  def store(val)
    val
  end
restore(val)

restores object from string form, restore(store(val)) must return val. If you override store, you should override restore to reverse the action. For example, if you always just handle strings use:

  def restore(val)
    val
  end
[](key)

lookup a key in the registry

[]=(key,value)

set a key in the registry

set_default(default)

set the default value for registry lookups, if the key sought is not found, the default will be returned. The default default (har) is nil.

each(&block)

just like Hash#each

each_key(&block)

just like Hash#each_key

each_value(&block)

just like Hash#each_value

has_key?(key)

just like Hash#has_key?

has_both?(key, value)

just like Hash#has_both?

has_value?(value)

just like Hash#has_value?

index(value)

just like Hash#index?

delete(key)

delete a key from the registry

keys()

returns a list of your keys

to_a()

Return an array of all associations [key, value] in your namespace

to_hash()

Return an hash of all associations {key => value} in your namespace

clear()

empties the registry (restricted to your namespace)

values()

returns an array of the values in your namespace of the registry

length()

returns the number of keys in your registry namespace

flush()