Class: SolidCable::Message
- Defined in:
- app/models/solid_cable/message.rb
Class Method Summary collapse
- .broadcast(channel, payload) ⇒ Object
-
.channel_hash_for(channel) ⇒ Object
Need to unpack this as a signed integer since Postgresql and SQLite don’t support unsigned integers.
- .channel_hashes_for(channels) ⇒ Object
Methods inherited from Record
Class Method Details
.broadcast(channel, payload) ⇒ Object
14 15 16 17 |
# File 'app/models/solid_cable/message.rb', line 14 def broadcast(channel, payload) insert({ created_at: Time.current, channel:, payload:, channel_hash: channel_hash_for(channel) }) end |
.channel_hash_for(channel) ⇒ Object
Need to unpack this as a signed integer since Postgresql and SQLite don’t support unsigned integers
25 26 27 |
# File 'app/models/solid_cable/message.rb', line 25 def channel_hash_for(channel) Digest::SHA256.digest(channel.to_s).unpack1("q>") end |
.channel_hashes_for(channels) ⇒ Object
19 20 21 |
# File 'app/models/solid_cable/message.rb', line 19 def channel_hashes_for(channels) channels.map { |channel| channel_hash_for(channel) } end |