lib/sugar-high/hash.rb in sugar-high-0.6.3 vs lib/sugar-high/hash.rb in sugar-high-0.7.0
- old
+ new
@@ -7,21 +7,21 @@
inject({}) do |rewritten_hash, (original_key, value)|
rewritten_hash[mapping.fetch(original_key, original_key)] = value
rewritten_hash
end
end
-
+
def hash_revert
r = Hash.new {|h,k| h[k] = []}
each {|k,v| r[v] << k}
r
- end
-
+ end
+
def try_keys *keys
option = last_option keys
- keys.flatten.each do |key|
+ keys.flatten.each do |key|
return self[key] if self[key]
- end
+ end
return option[:default] if option[:default]
nil
end
end