Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-templater.rb,
lib/simple-templater/core_exts.rb

Instance Method Summary collapse

Instance Method Details

#reverse_merge!(hash) ⇒ Object



5
6
7
# File 'lib/simple-templater.rb', line 5

def reverse_merge!(hash)
  self.replace(hash.merge(self))
end

#symbolize_keysHash

Return duplication of self with all keys non-recursively converted to symbols

Returns:

  • (Hash)

    A hash with all keys transformed into symbols

Author:

  • Botanicus

Since:

  • 0.0.2



84
85
86
87
88
89
# File 'lib/simple-templater/core_exts.rb', line 84

def symbolize_keys
  self.inject(Hash.new) do |result, array|
    result[array.first.to_sym] = array.last
    result
  end
end

#symbolize_keys!Hash

Replace keys in self by coresponding symbols

Returns:

  • (Hash)

    A hash with all keys transformed into symbols

Author:

  • Botanicus

Since:

  • 0.0.2



96
97
98
# File 'lib/simple-templater/core_exts.rb', line 96

def symbolize_keys!
  self.replace(self.symbolize_keys)
end