Class: Mincer::Processors::Pagination::Processor
- Inherits:
-
Object
- Object
- Mincer::Processors::Pagination::Processor
- Defined in:
- lib/mincer/processors/pagination/processor.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(mincer) ⇒ Processor
constructor
A new instance of Processor.
- #page ⇒ Object
- #per_page ⇒ Object
Constructor Details
#initialize(mincer) ⇒ Processor
Returns a new instance of Processor.
5 6 7 |
# File 'lib/mincer/processors/pagination/processor.rb', line 5 def initialize(mincer) @mincer, @args, @relation = mincer, mincer.args, mincer.relation end |
Class Method Details
.kaminari? ⇒ Boolean
20 21 22 |
# File 'lib/mincer/processors/pagination/processor.rb', line 20 def self.kaminari? defined?(::Kaminari) end |
.will_paginate? ⇒ Boolean
24 25 26 |
# File 'lib/mincer/processors/pagination/processor.rb', line 24 def self.will_paginate? defined?(::WillPaginate) end |
Instance Method Details
#apply ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mincer/processors/pagination/processor.rb', line 9 def apply if self.class.kaminari? @relation.page(page).per(per_page) elsif self.class.will_paginate? @relation.paginate(page: page, per_page: per_page) else warn 'To enable pagination please add kaminari or will_paginate to your Gemfile' @relation end end |