Module: SparkleFormation::SparkleAttribute
- Included in:
- SparkleStruct, SparkleFormation::SparkleStruct::Aws, SparkleFormation::SparkleStruct::Azure, SparkleFormation::SparkleStruct::Google, SparkleFormation::SparkleStruct::Heat, SparkleFormation::SparkleStruct::Rackspace, SparkleFormation::SparkleStruct::Terraform, Translation
- Defined in:
- lib/sparkle_formation/sparkle_attribute.rb,
lib/sparkle_formation/sparkle_attribute/aws.rb,
lib/sparkle_formation/sparkle_attribute/heat.rb,
lib/sparkle_formation/sparkle_attribute/azure.rb,
lib/sparkle_formation/sparkle_attribute/google.rb,
lib/sparkle_formation/sparkle_attribute/rackspace.rb,
lib/sparkle_formation/sparkle_attribute/terraform.rb
Overview
Provides template helper methods
Defined Under Namespace
Modules: Aws, Azure, Google, Heat, Rackspace, Terraform
Constant Summary collapse
- OpenStack =
Heat
Instance Method Summary collapse
-
#__attribute_key(key) ⇒ String
Format the provided key.
- #_dynamic(name, *args) {|new_struct| ... } ⇒ self (also: #dynamic!)
-
#_method(sym) ⇒ Method
(also: #method!)
Lookup a method definition on self.
-
#_nest(template, *names, options = {}) ⇒ self
(also: #nest!)
Nest a stack resource.
-
#_puts(obj, ...) ⇒ NilClass
(also: #puts!)
Print to stdout.
-
#_raise(*args) ⇒ Object
(also: #raise!)
Raise an exception.
-
#_registry(name, *args) ⇒ Object
(also: #registry!)
Return value of registry item.
-
#_resource_name ⇒ String
(also: #resource_name!)
Return current resource name.
-
#_system(command) ⇒ String
(also: #system!)
Execute system command.
Instance Method Details
#__attribute_key(key) ⇒ String
Format the provided key. If symbol type is provided formatting is forced. Otherwise the default formatting is applied
151 152 153 154 155 156 157 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 151 def __attribute_key(key) if key.is_a?(::Symbol) || key.is_a?(::String) _process_key(key, key.is_a?(::Symbol) ? :force : nil) else key end end |
#_dynamic(resource_type, custom_name, options = {}) ⇒ self #_dynamic(dynamic_name, custom_name, options = {}) ⇒ self Also known as: dynamic!
101 102 103 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 101 def _dynamic(name, *args, &block) SparkleFormation.insert(name, self, *args, &block) end |
#_method(sym) ⇒ Method Also known as: method!
Note:
usually used as puts! method!(:foo).source_location
76 77 78 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 76 def _method(*args) ::Kernel.instance_method(:method).bind(self).call(*args) end |
#_nest(template, *names, options = {}) ⇒ self Also known as: nest!
139 140 141 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 139 def _nest(template, *args, &block) SparkleFormation.nest(template, self, *args, &block) end |
#_puts(obj, ...) ⇒ NilClass Also known as: puts!
56 57 58 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 56 def _puts(*args) $stdout.puts(*args) end |
#_raise(*args) ⇒ Object Also known as: raise!
Raise an exception
64 65 66 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 64 def _raise(*args) ::Kernel.raise(*args) end |
#_registry(name) ⇒ Object #_registry(name, *args, options = {}) ⇒ Object Also known as: registry!
Return value of registry item
119 120 121 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 119 def _registry(name, *args) SparkleFormation.registry(name, self, *args) end |
#_resource_name ⇒ String Also known as: resource_name!
Return current resource name
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 18 def _resource_name result = nil if _parent if _parent._parent == _root result = _parent._data.detect do |r_name, r_value| r_value == self end result = result.first if result else result = _parent._resource_name end end unless result ::Kernel.raise NameError.new "Failed to determine current resource name! (Check call location)" end if result.is_a?(::SparkleFormation::FunctionStruct) result = result._clone end result end |
#_system(command) ⇒ String Also known as: system!
Execute system command
45 46 47 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 45 def _system(command) ::Kernel.send("`", command) end |