Files
fizzy/app/models/bubble/poppable.rb
T
Kevin McConnell 66d0f29d45 Notify on pop as well
And DRY up some duplication.
2025-01-13 14:21:47 +00:00

26 lines
399 B
Ruby

module Bubble::Poppable
extend ActiveSupport::Concern
included do
has_one :pop, dependent: :destroy
scope :popped, -> { joins(:pop) }
scope :active, -> { where.missing(:pop) }
end
def popped?
pop.present?
end
def pop!(user: Current.user)
unless popped?
create_pop!(user: user)
track_event :popped
end
end
def unpop
pop&.destroy
end
end