A basic storage backed by YAML, using one file per plugin.
(see Storage#initialize)
# File lib/cinch/storage/yaml.rb, line 9 def initialize(options, plugin) # We are a basic example, so we load everything into memory. yey. @file = options.basedir + plugin.class.plugin_name + ".yaml" if File.exist?(@file) @yaml = ::YAML.load_file(@file) || {} else @yaml = {} end @options = options @mutex = Mutex.new end
(see Storage#[])
# File lib/cinch/storage/yaml.rb, line 23 def [](key) @yaml[key] end
(see Strage#[]=)
# File lib/cinch/storage/yaml.rb, line 28 def []=(key, value) @yaml[key] = value end
(see Storage#delete)
# File lib/cinch/storage/yaml.rb, line 62 def delete(key) obj = @yaml.delete(key) obj end
(see Storage#delete_if)
# File lib/cinch/storage/yaml.rb, line 69 def delete_if delete_keys = [] each do |key, value| delete_keys << key if yield(key, value) end delete_keys.each do |key| delete(key) end self end
(see Storage#each)
# File lib/cinch/storage/yaml.rb, line 41 def each @yaml.each {|e| yield(e)} self end
(see Storage#each_key)
# File lib/cinch/storage/yaml.rb, line 48 def each_key @yaml.each_key {|e| yield(e)} self end
(see Storage#each_value)
# File lib/cinch/storage/yaml.rb, line 55 def each_value @yaml.each_value {|e| yield(e)} self end
(see Storage#has_key?)
# File lib/cinch/storage/yaml.rb, line 33 def has_key?(key) @yaml.has_key?(key) end
(see Storage#save)
# File lib/cinch/storage/yaml.rb, line 83 def save @mutex.synchronize do File.open(@file, "w") do |f| f.write @yaml.to_yaml end end end
(see Storage#unload)
# File lib/cinch/storage/yaml.rb, line 92 def unload end
Generated with the Darkfish Rdoc Generator 2.