Class Irc::Bot::Registry::Accessor
In: lib/rbot/registry.rb
Parent: Object

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   close   default   delete   each   each_key   each_value   flush   has_both?   has_key?   has_value?   include?   index   key?   keys   length   member?   new   registry   restore   set_default   size   store   sub_registry   to_a   to_hash   truncate   values  

Attributes

recovery  [RW] 

Public Class methods

plugins don‘t call this - a Registry::Accessor is created for them and is accessible via @registry.

Public Instance methods

lookup a key in the registry

set a key in the registry

empties the registry (restricted to your namespace)

just like Hash#each

just like Hash#each_key

just like Hash#each_value

just like Hash#has_both?

just like Hash#has_key?

just like Hash#has_value?

include?(key)

Alias for has_key?

just like Hash#index?

key?(key)

Alias for has_key?

returns a list of your keys

returns the number of keys in your registry namespace

member?(key)

Alias for has_key?

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

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.

size()

Alias for length

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

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

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

truncate()

Alias for clear

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

[Validate]