Parent

Object

Public Instance Methods

except(*keys) click to toggle source

Returns a new hash without the given keys.

# 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) click to toggle source

Replaces the hash without only the given keys.

# File lib/will_paginate/core_ext.rb, line 24
def except!(*keys)
  replace(except(*keys))
end
method_missing(method, *args) click to toggle source
# File lib/will_paginate/named_scope_patch.rb, line 26
def method_missing(method, *args)
  if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))
    super
  elsif @reflection.klass.scopes.include?(method)
    @reflection.klass.scopes[method].call(self, *args)
  else
    @reflection.klass.with_scope(:find => { :conditions => @finder_sql, :joins => @join_sql, :readonly => false }) do
      @reflection.klass.send(method, *args) { |*a| yield(*a) if block_given? }
    end
  end
end
method_missing_without_paginate(method, *args) click to toggle source
# File lib/will_paginate/named_scope_patch.rb, line 13
def method_missing_without_paginate(method, *args)
  if @reflection.klass.scopes.include?(method)
    @reflection.klass.scopes[method].call(self, *args) { |*a| yield(*a) if block_given? }
  else
    method_missing_without_scopes(method, *args) { |*a| yield(*a) if block_given? }
  end
end
method_missing_without_scopes(method, *args) click to toggle source
paginate(options = {}) click to toggle source
# File lib/will_paginate/array.rb, line 5
def paginate(options = {})
  raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options
  
  WillPaginate::Collection.create(
      options[:page] || 1,
      options[:per_page] || 30,
      options[:total_entries] || self.length
  ) { |pager|
    pager.replace self[pager.offset, pager.per_page].to_a
  }
end
slice(*keys) click to toggle source

Returns a new hash with only the given keys.

# 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) click to toggle source

Replaces the hash with only the given keys.

# File lib/will_paginate/core_ext.rb, line 39
def slice!(*keys)
  replace(slice(*keys))
end
with_scope(*args) click to toggle source
# File lib/will_paginate/named_scope_patch.rb, line 3
def with_scope(*args)
  @reflection.klass.send(:with_scope, *args) { |*a| yield(*a) if block_given? }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.