user_callout.rb 647 Bytes
Newer Older
1 2
# frozen_string_literal: true

3
class UserCallout < ApplicationRecord
Matija Čupić's avatar
Matija Čupić committed
4
  belongs_to :user
5

6
  # We use `UserCalloutEnums.feature_names` here so that EE can more easily
7
  # extend this `Hash` with new values.
8
  enum feature_name: ::UserCalloutEnums.feature_names
9

10
  validates :user, presence: true
11 12 13 14
  validates :feature_name,
    presence: true,
    uniqueness: { scope: :user_id },
    inclusion: { in: UserCallout.feature_names.keys }
15 16 17

  scope :with_feature_name, -> (feature_name) { where(feature_name: UserCallout.feature_names[feature_name]) }
  scope :with_dismissed_after, -> (dismissed_after) { where('dismissed_at > ?', dismissed_after) }
Matija Čupić's avatar
Matija Čupić committed
18
end