Class: Gitlab::Ci::Build::Policy::Variables

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

Constant Summary

Constants inherited from Specification

Specification::UnknownPolicyError

Instance Method Summary collapse

Constructor Details

#initialize(expressions) ⇒ Variables

Returns a new instance of Variables.


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

def initialize(expressions)
  @expressions = Array(expressions)
end

Instance Method Details

#satisfied_by?(pipeline, context) ⇒ Boolean

Returns:

  • (Boolean)

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

def satisfied_by?(pipeline, context)
  variables = context.variables

  statements = @expressions.map do |statement|
    ::Gitlab::Ci::Pipeline::Expression::Statement
      .new(statement, variables)
  end

  statements.any?(&:truthful?)
end