core_ext.rb

lib/will_paginate/core_ext.rb (view online)
Last Update: Thu May 21 21:34:32 +0000 2009

Methods

public instance

  1. except
  2. except!
  3. slice
  4. slice!

Required files

  1. set
  2. will_paginate/array

Public instance methods

except (*keys)

Returns a new hash without the given keys.

[show source]
# File lib/will_paginate/core_ext.rb, line 18
    def except(*keys)
      rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
      reject { |key,| rejected.include?(key) }
    end
except! (*keys)

Replaces the hash without only the given keys.

[show source]
# File lib/will_paginate/core_ext.rb, line 24
    def except!(*keys)
      replace(except(*keys))
    end
slice (*keys)

Returns a new hash with only the given keys.

[show source]
# File lib/will_paginate/core_ext.rb, line 33
    def slice(*keys)
      allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
      reject { |key,| !allowed.include?(key) }
    end
slice! (*keys)

Replaces the hash with only the given keys.

[show source]
# File lib/will_paginate/core_ext.rb, line 39
    def slice!(*keys)
      replace(slice(*keys))
    end