Module: Encore::Serializer::MetaManager
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/encore/serializer/meta_manager.rb
Class Method Summary collapse
- .add(collection, serializer, options) ⇒ Object
- .paginate_collection(collection, options) ⇒ Object
- .pagination_for(collection) ⇒ Object
Class Method Details
.add(collection, serializer, options) ⇒ Object
12 13 14 15 16 |
# File 'lib/encore/serializer/meta_manager.rb', line 12 def self.add(collection, serializer, ) return {} if [:skip_paging] { serializer.root_key => pagination_for(collection) } end |
.paginate_collection(collection, options) ⇒ Object
6 7 8 9 10 |
# File 'lib/encore/serializer/meta_manager.rb', line 6 def self.paginate_collection(collection, ) return collection if [:skip_paging] collection.page([:page]).per([:per_page]) end |
.pagination_for(collection) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/encore/serializer/meta_manager.rb', line 18 def self.pagination_for(collection) { page: collection.current_page, count: collection.total_count, page_count: collection.num_pages, previous_page: collection.prev_page, next_page: collection.next_page } end |