Module: Joggle::Store::PStore::Message

Included in:
All
Defined in:
lib/joggle/store/pstore/message.rb

Overview

Mixin that implements message store methods for pstore objects

Note: You’re probably looking for Joggle::Store::PStore::All

Instance Method Summary collapse

Instance Method Details

#add_message(key, row) ⇒ Object

Add message to store.



15
16
17
18
19
20
21
# File 'lib/joggle/store/pstore/message.rb', line 15

def add_message(key, row)
  key = message_store_key(key)

  @store.transaction do |s|
    s[key] = row
  end
end

#delete_message(key) ⇒ Object

Delete the given message.



37
38
39
40
41
42
43
# File 'lib/joggle/store/pstore/message.rb', line 37

def delete_message(key)
  key = message_store_key(key)

  @store.transaction do |s|
    s.delete(key)
  end
end

#has_message?(key) ⇒ Boolean

Does the given message exist in this store?

Returns:

  • (Boolean)


26
27
28
29
30
31
32
# File 'lib/joggle/store/pstore/message.rb', line 26

def has_message?(key)
  key = message_store_key(key)

  @store.transaction(true) do |s|
    s.root?(key)
  end
end

#message_store_key(key) ⇒ Object

Map given key to PStore root key.



48
49
50
# File 'lib/joggle/store/pstore/message.rb', line 48

def message_store_key(key)
  'message-' << Digest::MD5.hexdigest(key.to_s)
end