From c2f8deb3bbf44b4bb2996a883c3b7eaef7e52c63 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 4 Sep 2007 01:50:40 +0000 Subject: New Auth Framework: dream about auto-notifying hashes, and use #replace() when loading data --- lib/rbot/botuser.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb index c3c37a50..76785be8 100644 --- a/lib/rbot/botuser.rb +++ b/lib/rbot/botuser.rb @@ -10,6 +10,22 @@ require 'singleton' require 'set' +# This would be a good idea if it was failproof, but the truth +# is that other methods can indirectly modify the hash. *sigh* +# +# class AuthNotifyingHash < Hash +# %w(clear default= delete delete_if replace invert +# merge! update rehash reject! replace shift []= store).each { |m| +# class_eval { +# define_method(m) { |*a| +# r = super(*a) +# Irc::Auth.authmanager.set_changed +# r +# } +# } +# } +# end +# module Irc @@ -274,6 +290,7 @@ module Irc @perm = {} + # @data = AuthNotifyingHash.new @data = {} end @@ -345,7 +362,7 @@ module Irc @perm = h[:perm] if h.has_key?(:perm) @login_by_mask = h[:login_by_mask] if h.has_key?(:login_by_mask) @autologin = h[:autologin] if h.has_key?(:autologin) - @data = h[:data] if h.has_key?(:data) + @data.replace(h[:data]) if h.has_key?(:data) end # This method sets the password if the proposed new password -- cgit v1.2.3