class Temple::ImmutableHash
Immutable hash class which supports hash merging @api public
Public Class Methods
new(*hash)
click to toggle source
# File lib/temple/hash.rb, line 7 def initialize(*hash) @hash = hash.compact end
Public Instance Methods
[](key)
click to toggle source
# File lib/temple/hash.rb, line 15 def [](key) @hash.each {|h| return h[key] if h.include?(key) } nil end
each() { |k, self| ... }
click to toggle source
# File lib/temple/hash.rb, line 20 def each keys.each {|k| yield(k, self[k]) } end
include?(key)
click to toggle source
# File lib/temple/hash.rb, line 11 def include?(key) @hash.any? {|h| h.include?(key) } end
keys()
click to toggle source
# File lib/temple/hash.rb, line 24 def keys @hash.inject([]) {|keys, h| keys.concat(h.keys) }.uniq end
to_hash()
click to toggle source
# File lib/temple/hash.rb, line 32 def to_hash result = {} each {|k, v| result[k] = v } result end
values()
click to toggle source
# File lib/temple/hash.rb, line 28 def values keys.map {|k| self[k] } end