Sha256: cd8897a2cb69f748947e76bb77a331d548898eeedf5823f3c1fb9abc17282ea0

Contents?: true

Size: 639 Bytes

Versions: 2

Compression:

Stored size: 639 Bytes

Contents

module ApiPack
  module ApiHelper
    def pagination_meta_generator(request, total_pages)
      ApiPack::PaginationMetaGenerator.new(request: request, total_pages: total_pages).call
    end

    def current_page
      return params[:page].to_i if defined?(params[:page]) && !params[:page].nil?

      ApiPack::DEFAULT_PAGE
    end

    def per_page
      return params[:per_page].to_i if defined?(params[:per_page]) && !params[:per_page].nil?

      ApiPack.default_per_page
    end

    def serializer_hash(resource, class_name, opt: {})
      ApiPack::Serializer::Parser.serializer_hash(resource, class_name, opt: opt)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_pack-1.3.1 lib/api_pack/api_helper.rb
api_pack-1.2.1 lib/api_pack/api_helper.rb