Sha256: 0d2407cf07d7c683cd57950428c459838a809ae203de10d5c78a141f113795d6

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

module Animoto
  module Support
    module Hash
      
      # Returns a new hash with only the listed keys from this hash.
      #
      # @param [Array<Object>] keys the keys to include
      # @return [Hash{Object=>Object}] a new hash with only the listed keys
      def only *keys
        self.delete_if { |k,v| !keys.include?(k) }
      end
      
      # Returns a new hash with all keys from this hash except the listed ones.
      #
      # @param [Array<Object>] keys the keys to exclude
      # @return [Hash{Object=>Object}] a new hash without the listed keys
      def except *keys
        self.delete_if { |k,v| keys.include?(v) }
      end
      
    end
  end
end

Hash.__send__ :include, Animoto::Support::Hash

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
animoto-1.0.0 ./lib/animoto/support/hash.rb