2018-08-03 07:15:25 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-26 01:42:46 +00:00
|
|
|
module Ci
|
2021-08-03 06:08:50 +00:00
|
|
|
class Variable < Ci::ApplicationRecord
|
2020-03-18 12:09:13 +00:00
|
|
|
include Ci::HasVariable
|
2017-05-03 18:51:55 +00:00
|
|
|
include Presentable
|
2020-03-18 12:09:13 +00:00
|
|
|
include Ci::Maskable
|
2019-08-08 18:51:52 +00:00
|
|
|
prepend HasEnvironmentScope
|
2016-09-09 01:01:49 +00:00
|
|
|
|
2017-03-17 23:06:11 +00:00
|
|
|
belongs_to :project
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2018-03-17 11:17:40 +00:00
|
|
|
alias_attribute :secret_value, :value
|
|
|
|
|
2018-02-23 00:19:46 +00:00
|
|
|
validates :key, uniqueness: {
|
|
|
|
scope: [:project_id, :environment_scope],
|
|
|
|
message: "(%{value}) has already been taken"
|
|
|
|
}
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-05-31 14:45:51 +00:00
|
|
|
scope :unprotected, -> { where(protected: false) }
|
2020-07-08 09:09:17 +00:00
|
|
|
scope :by_environment_scope, -> (environment_scope) { where(environment_scope: environment_scope) }
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|