Class: Cinch::UserManager
- Inherits:
-
CacheManager
- Object
- CacheManager
- Cinch::UserManager
- Defined in:
- lib/cinch/user_manager.rb
Instance Method Summary collapse
- #delete(user) ⇒ Object private
-
#find(nick) ⇒ User?
Finds a user.
-
#find_ensured(*args) ⇒ User
Finds or creates a user.
- #update_nick(user) ⇒ Object private
Methods inherited from CacheManager
Constructor Details
This class inherits a constructor from Cinch::CacheManager
Instance Method Details
#delete(user) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 |
# File 'lib/cinch/user_manager.rb', line 56 def delete(user) @cache.delete_if {|n, u| u == user } end |
#find(nick) ⇒ User?
Finds a user.
42 43 44 45 |
# File 'lib/cinch/user_manager.rb', line 42 def find(nick) downcased_nick = nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"]) @cache[downcased_nick] end |
#find_ensured(nick) ⇒ User #find_ensured(user, nick, host) ⇒ User
Finds or creates a user.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cinch/user_manager.rb', line 21 def find_ensured(*args) case args.size when 1 nick = args.first = [nick] when 3 nick = args[1] = args else raise ArgumentError end downcased_nick = nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"]) @mutex.synchronize do @cache[downcased_nick] ||= User.new(*, @bot) end end |
#update_nick(user) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 53 |
# File 'lib/cinch/user_manager.rb', line 48 def update_nick(user) @mutex.synchronize do @cache[user.nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"])] = user @cache.delete user.last_nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"]) end end |