class Hash

Public Instance Methods

extract(*args) click to toggle source

Extract key-value pairs from self, given list of objects. If last object given is hash, it will be the collector for the extracted pairs. Extracted pairs are deleted from the original hash (self). Returns the extracted pairs as a hash or as the supplied collector hash. Attempts to ignore case.

# File lib/rack_warden/core_patches.rb, line 14
def extract(*args)
        other_hash = args.last.is_a?(Hash) ? args.pop : {}
        other_hash.tap do |other|
                self.delete_if {|k,v| (args.include?(k) || args.include?(k.to_s) || args.include?(k.to_s.downcase) || args.include?(k.to_sym)) || args.include?(k.to_s.downcase.to_sym) ? other[k]=v : nil}
        end
end