From 8f8205310518e7b0626d657ba9667f7bfc745371 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 16 Jul 2008 00:32:46 +0200 Subject: Dumpable definition of #any? and #all? methods for Channel#mode Commit 847a977b228b35f5ab281a31dd3724a4db887dff "#any? and #all? methods for Channel#mode to check if modes are set" turned Channel into a non-marshallable object because of singleton methods. Revert the commit and define an ad-hoc ModeHash class with the any? and all? methods, to make Channel#mode of that class. --- lib/rbot/irc.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 0be26a00..4ad57d99 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -1102,6 +1102,16 @@ module Irc end + # Hash of modes. Subclass of Hash that defines any? and all? + # to check if boolean modes (Type D) are set + class ModeHash < Hash + def any?(*ar) + !!ar.find { |m| s = m.to_sym ; self[s] && self[s].set? } + end + def all?(*ar) + !ar.find { |m| s = m.to_sym ; !(self[s] && self[s].set?) } + end + end # Channel modes of type A manipulate lists # @@ -1358,15 +1368,7 @@ module Irc } # Flags - @mode = {} - class << @mode - def any?(*ar) - !!ar.find { |m| s = m.to_sym ; self[s] && self[s].set? } - end - def all?(*ar) - !ar.find { |m| s = m.to_sym ; !(self[s] && self[s].set?) } - end - end + @mode = ModeHash.new end # Removes a user from the channel -- cgit v1.2.3