Module: Train::Platforms::Common

Included in:
Family, Platform
Defined in:
lib/train/platforms/common.rb

Instance Method Summary collapse

Instance Method Details

#detect(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/train/platforms/common.rb', line 21

def detect(&block)
  if block_given?
    @detect = block
    self
  elsif @detect.nil?
    # we are returning a block that just returns false here
    # to skip the family/platform evaluation if detect is not set
    ->(_) { false }
  else
    @detect
  end
end

#in_family(family) ⇒ Object

Add a family connection. This will create a family if it does not exist and add a child relationship.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/train/platforms/common.rb', line 7

def in_family(family)
  if self.class == Train::Platforms::Family && @name == family
    fail "Unable to add family #{@name} to itself: '#{@name}.in_family(#{family})'"
  end

  # add family to the family list
  family = Train::Platforms.family(family)
  family.children[self] = @condition

  @families[family] = @condition
  @condition = nil
  self
end