summaryrefslogtreecommitdiff
path: root/app/models/concerns/packages/installable.rb
blob: e9303e55412b6c5baf4494fea1c8c7d2caaba10d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

module Packages
  # This module requires a status column.
  # It also requires a constant INSTALLABLE_STATUSES. This should be
  # an array that defines which values of the status column are
  # considered as installable.
  module Installable
    extend ActiveSupport::Concern

    included do
      scope :with_status, ->(status) { where(status: status) }
      scope :installable, -> { with_status(const_get(:INSTALLABLE_STATUSES, false)) }
    end
  end
end