lib/refinements/hash_extensions.rb in refinements-2.1.0 vs lib/refinements/hash_extensions.rb in refinements-2.2.0
- old
+ new
@@ -2,9 +2,17 @@
module Refinements
# Refinements for Hashes.
module HashExtensions
refine Hash do
+ def compact
+ dup.compact!
+ end
+
+ def compact!
+ reject! { |_, value| value.nil? }
+ end
+
def deep_merge other_hash
dup.deep_merge! other_hash
end
def deep_merge! other_hash