summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-24 08:08:33 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-24 08:08:33 +0000
commite4d2961c1e0af6330ba49252ed0245a98514a270 (patch)
treeb847ff0e244420034aeb1ed277cb3aa5415f0c43 /lib
parentbdc901984c5fe7fb08ae0fa217c21a9ea1ba1ff5 (diff)
core/userdata: refactor set_data_hash method
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/userdata.rb27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/rbot/core/userdata.rb b/lib/rbot/core/userdata.rb
index 844a6c58..0164f659 100644
--- a/lib/rbot/core/userdata.rb
+++ b/lib/rbot/core/userdata.rb
@@ -76,6 +76,17 @@ class UserDataModule < CoreBotModule
return h[key]
end
+ def set_data_hash(user, h)
+ iu = user.to_irc_user
+ bu = iu.botuser
+
+ if bu.transient? or bu.default?
+ @ircuser[iu.nick] = h
+ else
+ @botuser[bu.username] = h
+ end
+ end
+
def set_data(user, key, value=nil, &block)
h = get_data_hash(user)
debug h
@@ -92,14 +103,8 @@ class UserDataModule < CoreBotModule
end
debug ret
- iu = user.to_irc_user
- bu = iu.botuser
+ set_data_hash(user, h)
- if bu.transient? or bu.default?
- @ircuser[iu.nick] = h
- else
- @botuser[bu.username] = h
- end
return ret
end
@@ -108,14 +113,8 @@ class UserDataModule < CoreBotModule
debug h
yield h
- iu = user.to_irc_user
- bu = iu.botuser
+ set_data_hash(user, h)
- if bu.transient? or bu.default?
- @ircuser[iu.nick] = h
- else
- @botuser[bu.username] = h
- end
return h
end