Sha256: ed73d84aa254d0016776ede9b069f8d6cd1ffb8a50665b988cc1b7f69c827e70

Contents?: true

Size: 359 Bytes

Versions: 2

Compression:

Stored size: 359 Bytes

Contents

module SafeCookies
  class Util
    class << self
      
      def slice(hash, *allowed_keys)
        sliced_hash = hash.select { |key, value|
          allowed_keys.include? key
        }

        # Normalize the result of Hash#select
        # (Ruby 1.8 returns an Array, Ruby 1.9 returns a Hash)
        Hash[sliced_hash]
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
safe_cookies-0.1.5 lib/safe_cookies/util.rb
safe_cookies-0.1.4 lib/safe_cookies/util.rb