Sha256: d79e2ae47d96f03143d95efb91a9e6bc8ca5ecad6b71d53b5381443462329d99

Contents?: true

Size: 871 Bytes

Versions: 37

Compression:

Stored size: 871 Bytes

Contents

require 'set'
require 'will_paginate/array'

unless Hash.instance_methods.include? 'except'
  Hash.class_eval do
    # Returns a new hash without the given keys.
    def except(*keys)
      rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
      reject { |key,| rejected.include?(key) }
    end
 
    # Replaces the hash without only the given keys.
    def except!(*keys)
      replace(except(*keys))
    end
  end
end

unless Hash.instance_methods.include? 'slice'
  Hash.class_eval do
    # Returns a new hash with only the given keys.
    def slice(*keys)
      allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
      reject { |key,| !allowed.include?(key) }
    end

    # Replaces the hash with only the given keys.
    def slice!(*keys)
      replace(slice(*keys))
    end
  end
end

Version data entries

37 entries across 37 versions & 20 rubygems

Version Path
decisiv-will_paginate-2.3.6.1 lib/will_paginate/core_ext.rb
decisiv-will_paginate-2.3.6 lib/will_paginate/core_ext.rb
decisiv-will_paginate-2.3.8.1 lib/will_paginate/core_ext.rb
dweinand-will_paginate-2.3.4 lib/will_paginate/core_ext.rb
dweinand-will_paginate-2.3.7 lib/will_paginate/core_ext.rb
fermion-will_paginate-2.3.8 lib/will_paginate/core_ext.rb
gcirne-will_paginate-2.3.8 lib/will_paginate/core_ext.rb
gohanlon-will_paginate-2.3.3 lib/will_paginate/core_ext.rb
jcnetdev-will_paginate-2.3.21 lib/will_paginate/core_ext.rb
kamal-will_paginate-2.3.8 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.2.3 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.0 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.1 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.2 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.3 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.4 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.5 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.6 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.7 lib/will_paginate/core_ext.rb
mislav-will_paginate-2.3.8 lib/will_paginate/core_ext.rb