Class: Malm::MessageDb
- Inherits:
-
Object
- Object
- Malm::MessageDb
- Defined in:
- lib/malm/message_db.rb
Instance Method Summary collapse
- #create(message) ⇒ Object
- #find(id) ⇒ Object
- #find_all ⇒ Object
-
#initialize ⇒ MessageDb
constructor
A new instance of MessageDb.
Constructor Details
#initialize ⇒ MessageDb
Returns a new instance of MessageDb.
6 7 8 9 10 |
# File 'lib/malm/message_db.rb', line 6 def initialize @sempahore = Mutex.new @message_db = [] end |
Instance Method Details
#create(message) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/malm/message_db.rb', line 12 def create() @sempahore.synchronize do [:id] = @message_db.size @message_db << @message_db.size end end |
#find(id) ⇒ Object
26 27 28 29 30 |
# File 'lib/malm/message_db.rb', line 26 def find(id) @sempahore.synchronize do @message_db[id].dup end end |
#find_all ⇒ Object
20 21 22 23 24 |
# File 'lib/malm/message_db.rb', line 20 def find_all @sempahore.synchronize do @message_db.dup end end |