lib/map.rb in map-2.6.0 vs lib/map.rb in map-2.6.1

- old
+ new

@@ -1,7 +1,7 @@ class Map < Hash - Version = '2.6.0' unless defined?(Version) + Version = '2.6.1' unless defined?(Version) Load = Kernel.method(:load) unless defined?(Load) class << Map def version Map::Version @@ -270,11 +270,11 @@ copy ensure self.default = default end - Dup = instance_method(:dup) + Dup = instance_method(:dup) unless defined?(Dup) def dup copy end @@ -602,9 +602,29 @@ collection = collection[k] return collection unless collection.respond_to?('[]') end return false unless(collection.is_a?(Hash) or collection.is_a?(Array)) collection_has_key?(collection, alphanumeric_key_for(key)) + end + + def blank?(*keys) + return empty? if keys.empty? + !has?(*keys) or Map.blank?(get(*keys)) + end + + def Map.blank?(value) + return value.blank? if value.respond_to?(:blank?) + + case value + when String + value.strip.empty? + when Numeric + value == 0 + when false + true + else + value.respond_to?(:empty?) ? value.empty? : !value + end end def collection_has_key?(collection, key) case collection when Hash