Method: Messaging::Adapters::Postgres::SerializedMessage.instantiate
- Defined in:
- lib/messaging/adapters/postgres/serialized_message.rb
.instantiate(attributes, *_args) ⇒ Object
We override this AR method to make records retreived from scopes etc. be message objects of the corresponding message class instead of AR objects
See api.rubyonrails.org/classes/ActiveRecord/Persistence/ClassMethods.html#method-i-instantiate
14 15 16 17 18 |
# File 'lib/messaging/adapters/postgres/serialized_message.rb', line 14 def self.instantiate(attributes, *_args) attributes['message_type'].constantize.new( JSON.parse(attributes['data']).merge(stream_position: attributes['stream_position']) ) end |