lib/jschat/storage/null.rb in jschat-0.1.5 vs lib/jschat/storage/null.rb in jschat-0.2.0
- old
+ new
@@ -1,18 +1,24 @@
module JsChat::Storage
+ MEMORY_MESSAGE_LIMIT = 100
+
module NullDriver
- def self.log(message)
+ def self.log(message, room)
@messages ||= []
+ message['room'] = room
@messages.push message
- @messages = @messages[-100..-1] if @messages.size > 100
+ @messages = @messages[-MEMORY_MESSAGE_LIMIT..-1] if @messages.size > MEMORY_MESSAGE_LIMIT
end
- def self.lastlog(number)
+ def self.lastlog(number, room)
@messages ||= []
- @messages[0..number]
+ @messages.select { |m| m['room'] == room }.reverse[0..number].reverse
end
- def self.find_user(name)
+ def self.find_user(options)
+ end
+
+ def self.save_user(user)
end
def self.set_rooms(name, rooms)
end
end