Class: DataMapper::Paginator::Control

Inherits:
Object
  • Object
show all
Defined in:
lib/dm-paginator/control.rb

Class Method Summary collapse

Class Method Details

.factory(paginator, kind = nil, options = {}) ⇒ Sliding|Elastic|Jumping|All

Factory.

Parameters:

  • paginator (Main)
  • kind (String) (defaults to: nil)
  • options (Hash) (defaults to: {})

Returns:

  • (Sliding|Elastic|Jumping|All)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dm-paginator/control.rb', line 13

def self.factory paginator, kind = nil, options = {}
  if !paginator.is_a?( Main )
    raise ArgumentError, "paginator argument is not an instance of Main"
  end
  
  case kind.downcase!
    when "sliding"
      return DataMapper::Paginator::ControlHelper::Sliding.new paginator, options
    when "elastic"
      return DataMapper::Paginator::ControlHelper::Elastic.new paginator, options
    when "jumping"
      return DataMapper::Paginator::ControlHelper::Jumping.new paginator, options
    when "all", kind.empty?
      return DataMapper::Paginator::ControlHelper::All.new paginator, options
  end
end