Created
June 8, 2015 21:26
-
-
Save juggy/5abec1b9d110ff88b823 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Core::PaginationSerializer < ActiveModel::ArraySerializer | |
def initialize(object, options={}) | |
meta_key = options[:meta_key] || :meta | |
options[meta_key] ||= {} | |
pobject = options[:pagination_object] || object | |
options[meta_key][:pagination] = { | |
current_page: pobject.current_page, | |
next_page: pobject.next_page, | |
prev_page: pobject.prev_page, | |
total_pages: pobject.total_pages, | |
total_count: pobject.total_count | |
} | |
super(object, options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is for Kaminari (pagination gem) and AMS