Class: Chatbox::MemoryStore
- Inherits:
-
Object
- Object
- Chatbox::MemoryStore
- Defined in:
- lib/chatbox/memory_store.rb
Defined Under Namespace
Classes: Record
Instance Method Summary collapse
- #add_message(attrs) ⇒ Object
- #find_all_messages_by_from_id(id) ⇒ Object
- #find_all_messages_by_to_id(id) ⇒ Object
- #find_message(id) ⇒ Object
- #mark_message_read!(id) ⇒ Object
- #mark_message_unread!(id) ⇒ Object
Instance Method Details
#add_message(attrs) ⇒ Object
3 4 5 |
# File 'lib/chatbox/memory_store.rb', line 3 def (attrs) attrs_list << attrs end |
#find_all_messages_by_from_id(id) ⇒ Object
27 28 29 |
# File 'lib/chatbox/memory_store.rb', line 27 def (id) attrs_list.select { |attrs| attrs['from_id'] == id }.map { |attrs| Record.new attrs } end |
#find_all_messages_by_to_id(id) ⇒ Object
23 24 25 |
# File 'lib/chatbox/memory_store.rb', line 23 def (id) attrs_list.select { |attrs| attrs['to_id'] == id }.map { |attrs| Record.new attrs } end |
#find_message(id) ⇒ Object
17 18 19 20 21 |
# File 'lib/chatbox/memory_store.rb', line 17 def (id) if attrs = attrs_list.detect { |attrs| attrs['id'] == id } Record.new attrs end end |
#mark_message_read!(id) ⇒ Object
7 8 9 |
# File 'lib/chatbox/memory_store.rb', line 7 def (id) attrs_list.detect { |attrs| attrs['id'] == id }.merge! 'read' => true end |
#mark_message_unread!(id) ⇒ Object
11 12 13 |
# File 'lib/chatbox/memory_store.rb', line 11 def (id) attrs_list.detect { |attrs| attrs['id'] == id }.merge! 'read' => false end |