Class: Ci::Trigger

Inherits:
ApplicationRecord show all
Extended by:
Gitlab::Ci::Model
Includes:
Presentable
Defined in:
app/models/ci/trigger.rb

Instance Method Summary collapse

Methods included from Gitlab::Ci::Model

model_name, table_name_prefix

Methods included from Presentable

#present

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Instance Method Details

#can_access_project?Boolean

Returns:

  • (Boolean)

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

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

#last_trigger_requestObject


22
23
24
# File 'app/models/ci/trigger.rb', line 22

def last_trigger_request
  trigger_requests.last
end

#last_usedObject


26
27
28
# File 'app/models/ci/trigger.rb', line 26

def last_used
  last_trigger_request.try(:created_at)
end

#set_default_valuesObject


18
19
20
# File 'app/models/ci/trigger.rb', line 18

def set_default_values
  self.token = SecureRandom.hex(15) if self.token.blank?
end

#short_tokenObject


30
31
32
# File 'app/models/ci/trigger.rb', line 30

def short_token
  token[0...4] if token.present?
end