Module: SparkleFormation::SparkleAttribute
- Included in:
- SparkleStruct, 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
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
140 141 142 143 144 145 146 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 140 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!
93 94 95 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 93 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`
69 70 71 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 69 def _method(*args) ::Kernel.instance_method(:method).bind(self).call(*args) end |
#_nest(template, *names, options = {}) ⇒ self Also known as: nest!
129 130 131 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 129 def _nest(template, *args, &block) SparkleFormation.nest(template, self, *args, &block) end |
#_puts(obj, ...) ⇒ NilClass Also known as: puts!
51 52 53 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 51 def _puts(*args) $stdout.puts(*args) end |
#_raise(*args) ⇒ Object Also known as: raise!
Raise an exception
58 59 60 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 58 def _raise(*args) ::Kernel.raise(*args) end |
#_registry(name) ⇒ Object #_registry(name, *args, options = {}) ⇒ Object Also known as: registry!
Return value of registry item
110 111 112 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 110 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 |
# 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 result end |
#_system(command) ⇒ String Also known as: system!
Execute system command
41 42 43 |
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 41 def _system(command) ::Kernel.send('`', command) end |