Class: Ci::Trigger

Inherits:
ApplicationRecord show all
Includes:
IgnorableColumns, Limitable, Presentable
Defined in:
app/models/ci/trigger.rb

Constant Summary collapse

TRIGGER_TOKEN_PREFIX =
'glptt-'

Constants included from Limitable

Limitable::GLOBAL_SCOPE

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Method Summary collapse

Methods included from Limitable

#exceeds_limits?

Methods included from Presentable

#present

Methods inherited from ApplicationRecord

model_name, table_name_prefix

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

#can_access_project?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/ci/trigger.rb', line 51

def can_access_project?
  Ability.allowed?(self.owner, :create_build, project)
end

#last_trigger_requestObject



39
40
41
# File 'app/models/ci/trigger.rb', line 39

def last_trigger_request
  trigger_requests.last
end

#last_usedObject



43
44
45
# File 'app/models/ci/trigger.rb', line 43

def last_used
  last_trigger_request.try(:created_at)
end

#set_default_valuesObject



35
36
37
# File 'app/models/ci/trigger.rb', line 35

def set_default_values
  self.token = "#{TRIGGER_TOKEN_PREFIX}#{SecureRandom.hex(20)}" if self.token.blank?
end

#short_tokenObject



47
48
49
# File 'app/models/ci/trigger.rb', line 47

def short_token
  token.delete_prefix(TRIGGER_TOKEN_PREFIX)[0...4] if token.present?
end