Class: Ci::Trigger
Constant Summary
collapse
- TRIGGER_TOKEN_PREFIX =
'glptt-'
Constants included
from Limitable
Limitable::GLOBAL_SCOPE
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Instance Method Summary
collapse
Methods included from Limitable
#exceeds_limits?
#present
model_name, table_name_prefix
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
#serializable_hash
Instance Method Details
#can_access_project? ⇒ 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_request ⇒ Object
39
40
41
|
# File 'app/models/ci/trigger.rb', line 39
def last_trigger_request
trigger_requests.last
end
|
#last_used ⇒ Object
43
44
45
|
# File 'app/models/ci/trigger.rb', line 43
def last_used
last_trigger_request.try(:created_at)
end
|
#set_default_values ⇒ Object
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_token ⇒ Object
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
|