Method: Temple::Utils#unique_name

Defined in:
lib/temple/utils.rb

#unique_name(prefix = nil) ⇒ String

Generate unique variable name

Parameters:

  • prefix (String) (defaults to: nil)

    Variable name prefix

Returns:



56
57
58
59
60
# File 'lib/temple/utils.rb', line 56

def unique_name(prefix = nil)
  @unique_name ||= 0
  prefix ||= (@unique_prefix ||= self.class.name.gsub('::'.freeze, '_'.freeze).downcase)
  "_#{prefix}#{@unique_name += 1}"
end