2020-07-15 18:09:09 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ApprovableBase
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
has_many :approvals, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
|
|
|
|
has_many :approved_by_users, through: :approvals, source: :user
|
|
|
|
end
|
|
|
|
|
2020-07-16 15:09:38 +00:00
|
|
|
def approved_by?(user)
|
2020-07-15 18:09:09 +00:00
|
|
|
return false unless user
|
|
|
|
|
|
|
|
approved_by_users.include?(user)
|
|
|
|
end
|
|
|
|
end
|