Class: CloudFormer::Functions::Join

Inherits:
CloudFormer::Function show all
Defined in:
lib/cloud_former/functions/join.rb

Instance Method Summary collapse

Constructor Details

#initialize(join_string, pieces) ⇒ Join

Returns a new instance of Join.



5
6
7
8
# File 'lib/cloud_former/functions/join.rb', line 5

def initialize(join_string, pieces)
  @join_string = join_string
  @pieces = pieces
end

Instance Method Details

#acts_as_string?Boolean

Returns:



10
11
12
# File 'lib/cloud_former/functions/join.rb', line 10

def acts_as_string?
  true
end

#dump_jsonObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cloud_former/functions/join.rb', line 14

def dump_json
  mapped_pieces = @pieces.map do |piece|
    if piece.is_a?(Parameter) || piece.is_a?(PseudoParameter)
      { 'Ref' => piece.get_name }
    elsif piece.is_a?(Function)
      piece.dump_json
    elsif piece.is_a?(Resource)
      { 'Ref' => piece.get_name }
    else
      piece
    end
  end

  {
    'Fn::Join' => [
      @join_string,
      mapped_pieces
    ]
  }
end