Class: CfnDsl::PropertyDefinition

Inherits:
JSONable
  • Object
show all
Defined in:
lib/monkey-patches/cfndsl_patch.rb

Overview

extends CfnDsl esource Properties to automatically substitute FnSub recuraively

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ PropertyDefinition

Returns a new instance of PropertyDefinition.



46
47
48
# File 'lib/monkey-patches/cfndsl_patch.rb', line 46

def initialize(value)
  @value = fix_substitutions(value)
end

Instance Method Details

#fix_array(val) ⇒ Object



63
64
65
# File 'lib/monkey-patches/cfndsl_patch.rb', line 63

def fix_array(val)
  val.map! { |item| fix_substitutions item }
end

#fix_hash(val) ⇒ Object



59
60
61
# File 'lib/monkey-patches/cfndsl_patch.rb', line 59

def fix_hash(val)
  val.transform_values! { |item| fix_substitutions item }
end

#fix_string(val) ⇒ Object

TODO Need to add exclusion if string is already a propoerty of FnSub…



68
69
70
# File 'lib/monkey-patches/cfndsl_patch.rb', line 68

def fix_string(val)
  val.include?('${') ? FnSub(val) : val
end

#fix_substitutions(val) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/monkey-patches/cfndsl_patch.rb', line 50

def fix_substitutions(val)
  return val unless defined? val.class.to_s.downcase

  meth = "fix_#{val.class.to_s.downcase}"
  return send(meth, val) if respond_to?(meth.to_sym)

  val
end