Module: SocketHelpers::ControllerHelpers
- Defined in:
- lib/socket_helpers.rb
Instance Method Summary collapse
Instance Method Details
#public_attrs(record) ⇒ Object
9 10 11 12 |
# File 'lib/socket_helpers.rb', line 9 def public_attrs(record) attrs = record.attributes.merge('record_class' => record.try(:published_class) || record.class.to_s.underscore) return Oj.dump(attrs) end |
#websocket_response(records, action) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/socket_helpers.rb', line 13 def websocket_response(records, action) records = [records] unless records.is_a?(Array) records.each do |record| class_name = record.try(:published_class) || record.class.to_s.underscore puts "triggered #{class_name} #{action}" WebsocketRails[class_name].trigger(action, public_attrs(record)) end end |