Files
fizzy/app/models/message.rb
T
2024-11-15 18:17:42 -06:00

20 lines
433 B
Ruby

class Message < ApplicationRecord
belongs_to :bubble, touch: true
delegated_type :messageable, types: Messageable::TYPES, inverse_of: :message, dependent: :destroy
scope :chronologically, -> { order created_at: :asc, id: :desc }
after_create :captured
after_destroy :uncaptured
private
def captured
messageable.captured_as(self)
end
def uncaptured
messageable.uncaptured_as(self)
end
end