Sha256: 59f80a7a890f51a8a6f2331902daec17bf07a5bc9078780f2bf875e490fdf732
Contents?: true
Size: 1.19 KB
Versions: 8
Compression:
Stored size: 1.19 KB
Contents
module Trax module Controller module Collection module Pageable extend ::ActiveSupport::Concern PAGINATION_META_METHODS = [ :current_page, :per_page, :size, :total_pages, :total_entries ].freeze included do collection_defaults :page => 1, :per_page => 25 end def pagination_params params[:page] ||= self.class.collection_options.page params[:per_page] ||= self.class.collection_options.per_page @pagination_params ||= { :page => params[:page], :per_page => params[:per_page] } end def collection @collection ||= super.paginate(pagination_params) end def collection_pagination_meta @collection_pagination_meta ||= ::Trax::Controller::Collection::Pageable::PAGINATION_META_METHODS.inject({}) do |h, key| h[key] = collection.try(key) h end end def collection_response_meta if collection_action? super.merge!(:pagination => collection_pagination_meta) else super end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems