Class: Gitlab::Ci::Build::Policy::Refs

Inherits:
Specification show all
Defined in:
lib/gitlab/ci/build/policy/refs.rb

Constant Summary

Constants inherited from Specification

Specification::UnknownPolicyError

Instance Method Summary collapse

Constructor Details

#initialize(refs) ⇒ Refs

Returns a new instance of Refs.


8
9
10
# File 'lib/gitlab/ci/build/policy/refs.rb', line 8

def initialize(refs)
  @patterns = Array(refs)
end

Instance Method Details

#satisfied_by?(pipeline, context = nil) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
15
16
17
18
19
# File 'lib/gitlab/ci/build/policy/refs.rb', line 12

def satisfied_by?(pipeline, context = nil)
  @patterns.any? do |pattern|
    pattern, path = pattern.split('@', 2)

    matches_path?(path, pipeline) &&
      matches_pattern?(pattern, pipeline)
  end
end