Class: ActiveRecordStreams::Message
- Inherits:
-
Object
- Object
- ActiveRecordStreams::Message
- Defined in:
- lib/active_record_streams/message.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(table_name, action_type, old_image, new_image) ⇒ Message
constructor
A new instance of Message.
- #json ⇒ Object
Constructor Details
#initialize(table_name, action_type, old_image, new_image) ⇒ Message
7 8 9 10 11 12 |
# File 'lib/active_record_streams/message.rb', line 7 def initialize(table_name, action_type, old_image, new_image) @table_name = table_name @action_type = action_type @old_image = old_image || new_image @new_image = new_image end |
Class Method Details
.from_json(json) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/active_record_streams/message.rb', line 14 def self.from_json(json) parsed_json = JSON.parse(json) new( parsed_json['TableName'], parsed_json['ActionType'], parsed_json['OldImage'], parsed_json['NewImage'] ) end |
Instance Method Details
#json ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/active_record_streams/message.rb', line 25 def json { EventID: SecureRandom.uuid, TableName: @table_name, ActionType: @action_type, OldImage: @old_image, NewImage: @new_image }.to_json end |