Class: CloudFormer::Functions::Not

Inherits:
CloudFormer::Function show all
Defined in:
lib/cloud_former/functions/or.rb,
lib/cloud_former/functions/not.rb

Instance Method Summary collapse

Constructor Details

#initialize(function) ⇒ Not

Returns a new instance of Not.



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

def initialize(*conditions)
  @conditions = conditions
end

Instance Method Details

#dump_jsonObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cloud_former/functions/or.rb', line 9

def dump_json
  mapped = @conditions.map do |cond|
    if cond.is_a?(Condition)
      { 'Condition' => cond.get_name }
    elsif cond.is_a?(Function)
      cond.dump_json
    elsif cond.respond_to?(:get_name)
      { 'Ref' => cond.get_name }
    elsif cond.respond_to?(:to_s)
      cond.to_s
    end
  end

  { 'Fn::Or' => mapped }
end