Class: ProjectSetting

Inherits:
ApplicationRecord show all
Includes:
EachBatch, Gitlab::Utils::StrongMemoize, IgnorableColumns
Defined in:
app/models/project_setting.rb

Constant Summary collapse

ALLOWED_TARGET_PLATFORMS =
%w[ios osx tvos watchos android].freeze

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Method Details

#emails_enabled?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'app/models/project_setting.rb', line 99

def emails_enabled?
  super && project.namespace.emails_enabled?
end

#human_squash_optionObject



77
78
79
80
81
82
83
84
# File 'app/models/project_setting.rb', line 77

def human_squash_option
  case squash_option
  when 'never' then 'Do not allow'
  when 'always' then 'Require'
  when 'default_on' then 'Encourage'
  when 'default_off' then 'Allow'
  end
end

#runner_registration_enabledObject



95
96
97
# File 'app/models/project_setting.rb', line 95

def runner_registration_enabled
  Gitlab::CurrentSettings.valid_runner_registrars.include?('project') && read_attribute(:runner_registration_enabled)
end

#show_diff_preview_in_email?Boolean

Returns:

  • (Boolean)


86
87
88
89
90
91
92
# File 'app/models/project_setting.rb', line 86

def show_diff_preview_in_email?
  if project.group
    super && project.group&.show_diff_preview_in_email?
  else
    !!super
  end
end

#squash_enabled_by_default?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/models/project_setting.rb', line 65

def squash_enabled_by_default?
  %w[always default_on].include?(squash_option)
end

#squash_readonly?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'app/models/project_setting.rb', line 69

def squash_readonly?
  %w[always never].include?(squash_option)
end

#target_platforms=(val) ⇒ Object



73
74
75
# File 'app/models/project_setting.rb', line 73

def target_platforms=(val)
  super(val&.map(&:to_s)&.sort)
end