lib/map.rb in map-6.5.0 vs lib/map.rb in map-6.5.1

- old
+ new

@@ -1,8 +1,8 @@ # -*- encoding : utf-8 -*- class Map < Hash - Version = '6.5.0' unless defined?(Version) + Version = '6.5.1' unless defined?(Version) Load = Kernel.method(:load) unless defined?(Load) class << Map def version Map::Version @@ -248,20 +248,14 @@ end def map_for(hash) klass.map_for(hash) end -=begin - def self.convert_key(key) + def Map.convert_key(key) key.kind_of?(Symbol) ? key.to_s : key end -=end - def self.convert_key(key) - key = key.kind_of?(Symbol) ? key.to_s : key - end - def convert_key(key) if klass.respond_to?(:convert_key) klass.convert_key(key) else Map.convert_key(key) @@ -470,26 +464,22 @@ end end def unshift(*args) Map.each_pair(*args) do |key, val| - if key?(key) - delete(key) - else - keys.unshift(key) - end + key = convert_key(key) + delete(key) + keys.unshift(key) __set__(key, val) end self end def push(*args) Map.each_pair(*args) do |key, val| - if key?(key) - delete(key) - else - keys.push(key) - end + key = convert_key(key) + delete(key) + keys.push(key) __set__(key, val) end self end