group_variable.rb 453 Bytes
Newer Older
1 2
# frozen_string_literal: true

Shinya Maeda's avatar
Shinya Maeda committed
3 4
module Ci
  class GroupVariable < ActiveRecord::Base
5
    extend Gitlab::Ci::Model
Shinya Maeda's avatar
Shinya Maeda committed
6 7
    include HasVariable
    include Presentable
8
    include Maskable
Shinya Maeda's avatar
Shinya Maeda committed
9

10
    belongs_to :group, class_name: "::Group"
Shinya Maeda's avatar
Shinya Maeda committed
11

12 13
    alias_attribute :secret_value, :value

14 15 16 17
    validates :key, uniqueness: {
      scope: :group_id,
      message: "(%{value}) has already been taken"
    }
Shinya Maeda's avatar
Shinya Maeda committed
18 19 20 21

    scope :unprotected, -> { where(protected: false) }
  end
end