lib/yaks/util.rb in yaks-0.4.4 vs lib/yaks/util.rb in yaks-0.5.0
- old
+ new
@@ -16,9 +16,13 @@
def camelize(str)
str.gsub(/\/(.?)/) { "::#{ $1.upcase }" }
.gsub!(/(?:^|_)(.)/) { $1.upcase }
end
+ def slice_hash(hash, *keys)
+ keys.each_with_object({}) {|k,dest| dest[k] = hash[k] if hash.key?(k) }
+ end
+
# Turn what is maybe a Proc into its result (or itself)
#
# When input can be either a value or a proc that returns a value,
# this conversion function can be used to resolve the thing to a
# value.