houdini/app/models/concerns/model/eventable.rb

21 lines
598 B
Ruby
Raw Normal View History

2021-02-02 21:04:53 +00:00
# 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
2021-02-02 21:04:53 +00:00
end