Module: SparkleFormation::SparkleAttribute
- Included in:
- SparkleStruct, Translation
- Defined in:
- lib/sparkle_formation/sparkle_attribute.rb
Overview
Provides template helper methods
Instance Method Summary collapse
-
#_cf_attr(*args) ⇒ Hash
(also: #_cf_get_att, #get_att!, #attr!)
Fn::GetAtt generator.
-
#_cf_base64(arg) ⇒ Hash
(also: #base64!)
Fn::Base64 generator.
-
#_cf_get_azs(region = nil) ⇒ Hash
(also: #get_azs!, #azs!)
Fn::GetAZs generator.
-
#_cf_join(*args) ⇒ Hash
(also: #join!)
Fn::Join generator.
-
#_cf_map(thing, key, *suffix) ⇒ Hash
(also: #_cf_find_in_map, #find_in_map!, #map!)
Fn::FindInMap generator.
-
#_cf_ref(thing) ⇒ Hash
(also: #_ref, #ref!)
Ref generator.
-
#_cf_select(index, item) ⇒ Hash
(also: #select!)
Fn::Select generator.
-
#_platform=(plat) ⇒ TrueClass
Set the destination platform.
- #debian? ⇒ TrueClass, FalseClass
-
#dynamic!(name, *args, &block) ⇒ self
Dynamic insertion helper method.
-
#registry!(name, *args) ⇒ self
Registry insertion helper method.
- #rhel? ⇒ TrueClass, FalseClass
Instance Method Details
#_cf_attr(*args) ⇒ Hash Also known as: _cf_get_att, get_att!, attr!
Fn::GetAtt generator
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 78 def _cf_attr(*args) args = args.map do |thing| if(thing.is_a?(Symbol)) _process_key(thing, :force) else thing end end {'Fn::GetAtt' => args} end |
#_cf_base64(arg) ⇒ Hash Also known as: base64!
Fn::Base64 generator
97 98 99 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 97 def _cf_base64(arg) {'Fn::Base64' => arg} end |
#_cf_get_azs(region = nil) ⇒ Hash Also known as: get_azs!, azs!
Fn::GetAZs generator
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 106 def _cf_get_azs(region=nil) region = case region when Symbol _cf_ref(region) when NilClass '' else region end {'Fn::GetAZs' => region} end |
#_cf_join(*args) ⇒ Hash Also known as: join!
Fn::Join generator
30 31 32 33 34 35 36 37 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 30 def _cf_join(*args) = args.detect{|i| i.is_a?(Hash) && i[:options]} || {:options => {}} args.delete() unless(args.size == 1) args = [args] end {'Fn::Join' => [[:options][:delimiter] || '', *args]} end |
#_cf_map(thing, key, *suffix) ⇒ Hash Also known as: _cf_find_in_map, find_in_map!, map!
Fn::FindInMap generator
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 58 def _cf_map(thing, key, *suffix) suffix = suffix.map do |item| if(item.is_a?(Symbol)) _process_key(item, :force) else item end end thing = _process_key(thing, :force) if thing.is_a?(Symbol) key = _process_key(key, :force) if key.is_a?(Symbol) {'Fn::FindInMap' => [_process_key(thing), {'Ref' => _process_key(key)}, *suffix]} end |
#_cf_ref(thing) ⇒ Hash Also known as: _ref, ref!
Note:
Symbol value will force key processing
Ref generator
45 46 47 48 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 45 def _cf_ref(thing) thing = _process_key(thing, :force) if thing.is_a?(Symbol) {'Ref' => thing} end |
#_cf_select(index, item) ⇒ Hash Also known as: select!
Fn::Select generator
125 126 127 128 129 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 125 def _cf_select(index, item) index = index.is_a?(Symbol) ? _cf_ref(index) : index item = _cf_ref(item) if item.is_a?(Symbol) {'Fn::Select' => [index, item]} end |
#_platform=(plat) ⇒ TrueClass
Set the destination platform
146 147 148 149 150 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 146 def _platform=(plat) @platform || __hashish @platform.clear @platform[plat.to_sym] = true end |
#debian? ⇒ TrueClass, FalseClass
138 139 140 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 138 def debian? !!@platform[:debian] end |
#dynamic!(name, *args, &block) ⇒ self
Dynamic insertion helper method
157 158 159 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 157 def dynamic!(name, *args, &block) SparkleFormation.insert(name, self, *args, &block) end |
#registry!(name, *args) ⇒ self
Registry insertion helper method
166 167 168 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 166 def registry!(name, *args) SfnRegistry.insert(name, self, *args) end |
#rhel? ⇒ TrueClass, FalseClass
133 134 135 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 133 def rhel? !!@platform[:rhel] end |