Class: Ci::JobToken::Allowlist
- Inherits:
-
Object
- Object
- Ci::JobToken::Allowlist
- Defined in:
- app/models/ci/job_token/allowlist.rb
Instance Method Summary collapse
- #add!(target_project, user:) ⇒ Object
- #includes?(target_project) ⇒ Boolean
-
#initialize(source_project, direction:) ⇒ Allowlist
constructor
A new instance of Allowlist.
- #projects ⇒ Object
Constructor Details
#initialize(source_project, direction:) ⇒ Allowlist
Returns a new instance of Allowlist.
5 6 7 8 |
# File 'app/models/ci/job_token/allowlist.rb', line 5 def initialize(source_project, direction:) @source_project = source_project @direction = direction end |
Instance Method Details
#add!(target_project, user:) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/models/ci/job_token/allowlist.rb', line 20 def add!(target_project, user:) Ci::JobToken::ProjectScopeLink.create!( source_project: @source_project, direction: @direction, target_project: target_project, added_by: user ) end |
#includes?(target_project) ⇒ Boolean
10 11 12 13 14 |
# File 'app/models/ci/job_token/allowlist.rb', line 10 def includes?(target_project) source_links .with_target(target_project) .exists? end |
#projects ⇒ Object
16 17 18 |
# File 'app/models/ci/job_token/allowlist.rb', line 16 def projects Project.from_union(target_projects, remove_duplicates: false) end |