Sha256: 229faba745525f29c18aefe3e13b0ec6eb2f947742b34636a3e45073bf8819a0
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
module LiveRecord module Model extend ActiveSupport::Concern included do has_many :live_record_updates, as: :recordable after_update :__live_record_reference_changed_attributes__ after_update_commit :__live_record_broadcast_record_update__ after_destroy_commit :__live_record_broadcast_record_destroy__ def self.live_record_whitelisted_attributes(record, current_user) [] end private def __live_record_reference_changed_attributes__ @_live_record_changed_attributes = changed end def __live_record_broadcast_record_update__ included_attributes = attributes.slice(*@_live_record_changed_attributes) @_live_record_changed_attributes = nil message_data = { 'action' => 'update', 'attributes' => included_attributes } LiveRecordChannel.broadcast_to(self, message_data) LiveRecordUpdate.create!(recordable: self) end def __live_record_broadcast_record_destroy__ message_data = { 'action' => 'destroy' } LiveRecordChannel.broadcast_to(self, message_data) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
live_record-0.0.4 | lib/live_record/model.rb |
live_record-0.0.3 | lib/live_record/model.rb |
live_record-0.0.1 | lib/live_record/model.rb |