59d7229500
Aligns with Rails conventions for organizing concerns in a dedicated concerns directory alongside existing concerns like Attachments, Mentions, Searchable, etc.
26 lines
548 B
Ruby
26 lines
548 B
Ruby
module Eventable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
has_many :events, as: :eventable, dependent: :destroy
|
|
end
|
|
|
|
def track_event(action, creator: Current.user, board: self.board, **particulars)
|
|
if should_track_event?
|
|
board.events.create!(action: "#{eventable_prefix}_#{action}", creator:, board:, eventable: self, particulars:)
|
|
end
|
|
end
|
|
|
|
def event_was_created(event)
|
|
end
|
|
|
|
private
|
|
def should_track_event?
|
|
true
|
|
end
|
|
|
|
def eventable_prefix
|
|
self.class.name.demodulize.underscore
|
|
end
|
|
end
|