Module: SideBoom::Attributes

Included in:
Job, Pipeline, Stage
Defined in:
lib/side_boom/attributes.rb

Overview

Attributes define the methods that can be set on both Pipeline, Stage, and Job level. Attributes set at pipeline level can be overriden at either stage- or job-level. Stage level attributes can be overriden by any of its jobs.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.array_attribute(*attrs) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/side_boom/attributes.rb', line 31

def array_attribute(*attrs)
  attrs.each do |attr|
    define_method(attr) do |args|
      args = [args] if args.is_a?(String)

      attributes[attr.to_s] = args.map(&:to_s)
    end
  end
end

.boolean_attribute(*attrs) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/side_boom/attributes.rb', line 7

def boolean_attribute(*attrs)
  attrs.each do |attr|
    define_method("#{attr}!") do
      @attributes[attr.to_s] = true
    end

    define_method("dis#{attr}!") do
      @attributes[attr.to_s] = false
    end

    define_method(attr) do |arg|
      @attributes[attr.to_s] = !!arg
    end
  end
end

.string_attribute(*attrs) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/side_boom/attributes.rb', line 23

def string_attribute(*attrs)
  attrs.each do |attr|
    define_method(attr) do |arg|
      attributes[attr.to_s] = arg.to_s
    end
  end
end

Instance Method Details

#attributesObject



46
47
48
# File 'lib/side_boom/attributes.rb', line 46

def attributes
  @attributes ||= {}
end