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/rackspace.rb

Overview

Provides template helper methods

Defined Under Namespace

Modules: Aws, Azure, Heat, Rackspace

Instance Method Summary collapse

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

Parameters:

  • key (String, Symbol)

    given key

Returns:

  • (String)

    formatted key



100
101
102
103
104
105
106
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 100

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

#_method(*args) ⇒ Method Also known as: method!

Lookup a method definition on self usually used as ‘puts! method!(:foo).source_location`

Returns:

  • (Method)


62
63
64
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 62

def _method(*args)
  ::Kernel.instance_method(:method).bind(self).call(*args)
end

#_puts(*args) ⇒ NilClass Also known as: puts!

Print to stdout

Parameters:

  • args

Returns:

  • (NilClass)


48
49
50
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 48

def _puts(*args)
  $stdout.puts(*args)
end

#_raise(*args) ⇒ Object Also known as: raise!

Raise an exception



54
55
56
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 54

def _raise(*args)
  ::Kernel.raise(*args)
end

#_resource_nameString Also known as: resource_name!

Return current resource name

Returns:

  • (String)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 16

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

Parameters:

  • command (String)

Returns:

  • (String)

    result



39
40
41
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 39

def _system(command)
  ::Kernel.send('`', command)
end

#dynamic!(name, *args, &block) ⇒ self

Dynamic insertion helper method

Parameters:

  • name (String, Symbol)

    dynamic name

  • args (Object)

    argument list for dynamic

Returns:

  • (self)


72
73
74
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 72

def dynamic!(name, *args, &block)
  SparkleFormation.insert(name, self, *args, &block)
end

#nest!(template, *args, &block) ⇒ self

Stack nesting helper method

Parameters:

  • template (String, Symbol)

    template to nest

  • args (String, Symbol)

    stringified and underscore joined for name

Returns:

  • (self)


90
91
92
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 90

def nest!(template, *args, &block)
  SparkleFormation.nest(template, self, *args, &block)
end

#registry!(name, *args) ⇒ self

Registry insertion helper method

Parameters:

  • name (String, Symbol)

    name of registry item

  • args (Object)

    argument list for registry

Returns:

  • (self)


81
82
83
# File 'lib/sparkle_formation/sparkle_attribute.rb', line 81

def registry!(name, *args)
  SparkleFormation.registry(name, self, *args)
end