Class: Gitlab::Ci::Build::Rules::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/build/rules/rule.rb

Defined Under Namespace

Classes: Clause

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Rule

Returns a new instance of Rule.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/ci/build/rules/rule.rb', line 13

def initialize(spec)
  @clauses    = []
  @attributes = {}

  spec.each do |type, value|
    if clause = Clause.fabricate(type, value)
      @clauses << clause
    else
      @attributes.merge!(type => value)
    end
  end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



7
8
9
# File 'lib/gitlab/ci/build/rules/rule.rb', line 7

def attributes
  @attributes
end

Class Method Details

.fabricate_list(list) ⇒ Object



9
10
11
# File 'lib/gitlab/ci/build/rules/rule.rb', line 9

def self.fabricate_list(list)
  list.map(&method(:new)) if list
end

Instance Method Details

#matches?(pipeline, context) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/gitlab/ci/build/rules/rule.rb', line 26

def matches?(pipeline, context)
  @clauses.all? { |clause| clause.satisfied_by?(pipeline, context) }
end