Module: NetLinx::ERB::HashHelpers

Defined in:
lib/netlinx/erb/hash_helpers.rb

Overview

A collection of helper methods for use in Hash

Instance Method Summary collapse

Instance Method Details

#append_suffixObject

Append the @tmpl_suffix to each key in the hash.



19
20
21
22
23
24
25
26
27
28
# File 'lib/netlinx/erb/hash_helpers.rb', line 19

def append_suffix
  hash = self.map do |k,v|
    key_name = "#{k}"
    key_name += "_#{tmpl_suffix}" if tmpl_suffix and not tmpl_suffix.empty?
    
    [key_name.to_sym, v]
  end
  
  Hash[hash]
end

#append_suffix!Object

Append the @tmpl_suffix to each key in the hash and overwrite this hash with the result.



32
33
34
35
36
# File 'lib/netlinx/erb/hash_helpers.rb', line 32

def append_suffix!
  hash = append_suffix
  self.clear
  self.merge! hash
end

#tmpl_suffixObject

Template suffix (capitalized / unmodified).



9
10
11
# File 'lib/netlinx/erb/hash_helpers.rb', line 9

def tmpl_suffix
  Hash.instance_variable_get :@tmpl_suffix
end

#tmpl_var_suffixObject

Template suffix for variables (lowercase).



14
15
16
# File 'lib/netlinx/erb/hash_helpers.rb', line 14

def tmpl_var_suffix
  Hash.instance_variable_get :@tmpl_var_suffix
end