Sha256: a1258cb8b4c14890540684de78f517bb925fb6e595bc5004409ad301d2e2a01a

Contents?: true

Size: 597 Bytes

Versions: 35

Compression:

Stored size: 597 Bytes

Contents

module Cms
  module Extensions
    module Hash
      #Returns a copy of the hash without the keys passed as arguments
      def except(*args)
        reject {|k,v| args.include?(k) }
      end
      
      # This takes a list of keys and returns a new hash 
      # containing the key/values that match the keys passed in. 
      # This will also remove the keys from this hash
      def extract!(*keys)
        keys.inject({}) do |hash, key|
          hash[key] = delete(key) if has_key?(key)
          hash
        end
      end      
    end
  end
end
Hash.send(:include, Cms::Extensions::Hash)

Version data entries

35 entries across 35 versions & 11 rubygems

Version Path
SFEley-browsercms-3.0.2 lib/cms/extensions/hash.rb
buzzware-browsercms-3.0.2 lib/cms/extensions/hash.rb
coredumplings-browsercms-3.0.0 lib/cms/extensions/hash.rb
nate-browsercms-3.0.210 lib/cms/extensions/hash.rb
nate-browsercms-3.0.211 lib/cms/extensions/hash.rb
we5-browsercms-3.0.1.1 lib/cms/extensions/hash.rb
webficient-browsercms-3.0.1 lib/cms/extensions/hash.rb
webficient-browsercms-3.0.2 lib/cms/extensions/hash.rb
webficient-browsercms-3.0.3 lib/cms/extensions/hash.rb
webficient-browsercms-3.0.4 lib/cms/extensions/hash.rb
browsercms-3.1.5 lib/cms/extensions/hash.rb
browsercms-3.1.4 lib/cms/extensions/hash.rb
browsercms-3.1.3 lib/cms/extensions/hash.rb
bf4-browsercms-3.1.0 lib/cms/extensions/hash.rb
drujensen-browsercms-3.2.0 lib/cms/extensions/hash.rb
browsercmsi-3.1.2 lib/cms/extensions/hash.rb
browsercms-3.1.2 lib/cms/extensions/hash.rb
browsercms-3.1.1 lib/cms/extensions/hash.rb
browsercmsi-3.1.1 lib/cms/extensions/hash.rb
browsercmsi-3.1.0 lib/cms/extensions/hash.rb