Class: Praxis::Extensions::Pagination::SequelPaginationHandler
- Inherits:
-
PaginationHandler
- Object
- PaginationHandler
- Praxis::Extensions::Pagination::SequelPaginationHandler
- Defined in:
- lib/praxis/extensions/pagination/sequel_pagination_handler.rb
Class Method Summary collapse
- .count(query) ⇒ Object
- .limit(query, limit) ⇒ Object
- .offset(query, offset) ⇒ Object
- .order(query, order, _root_resource: nil) ⇒ Object
- .where_gt(query, attr, value) ⇒ Object
- .where_lt(query, attr, value) ⇒ Object
Methods inherited from PaginationHandler
Class Method Details
.count(query) ⇒ Object
32 33 34 |
# File 'lib/praxis/extensions/pagination/sequel_pagination_handler.rb', line 32 def self.count(query) query.count end |
.limit(query, limit) ⇒ Object
40 41 42 |
# File 'lib/praxis/extensions/pagination/sequel_pagination_handler.rb', line 40 def self.limit(query, limit) query.limit(limit) end |
.offset(query, offset) ⇒ Object
36 37 38 |
# File 'lib/praxis/extensions/pagination/sequel_pagination_handler.rb', line 36 def self.offset(query, offset) query.offset(offset) end |
.order(query, order, _root_resource: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/praxis/extensions/pagination/sequel_pagination_handler.rb', line 17 def self.order(query, order, _root_resource: nil) return query unless order order_clause = order.map do |spec_hash| direction, name = spec_hash.first case direction.to_sym when :desc Sequel.desc(name.to_sym) else Sequel.asc(name.to_sym) end end query.order(*order_clause) end |
.where_gt(query, attr, value) ⇒ Object
13 14 15 |
# File 'lib/praxis/extensions/pagination/sequel_pagination_handler.rb', line 13 def self.where_gt(query, attr, value) query.where("#{attr} > ?", value) end |
.where_lt(query, attr, value) ⇒ Object
9 10 11 |
# File 'lib/praxis/extensions/pagination/sequel_pagination_handler.rb', line 9 def self.where_lt(query, attr, value) query.where("#{attr} < ?", value) end |