houdini/app/models/concerns/model/eventable.rb
Eric Schultz 2e8821efdf Initial Transaction and OfflineTransaction support
Co-authored-by: Clarissa Lima Borges <clarissa@commitchange.com>
2021-04-13 10:47:37 -05:00

21 lines
No EOL
598 B
Ruby

# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
module Model::Eventable
extend ActiveSupport::Concern
def to_event(event_type, *expand)
Jbuilder.new do |event|
event.id "objevt_" + SecureRandom.alphanumeric(22)
event.object 'object_event'
event.type event_type
event.data do
event.object to_builder(*expand)
end
end
end
def to_builder(*expand)
raise NotImplementedError.new("to_builder must be implemented in your model")
end
end