Sha256: cdeaae3986d4d7207446d83dc9835dab6f316f0781ea9e1885c75c8e0a205457
Contents?: true
Size: 1.08 KB
Versions: 5
Compression:
Stored size: 1.08 KB
Contents
module Encore module Serializer class OptionsParser def initialize(opts) @opts = opts end def include(serializer) opt = @opts[:include] output = [] # Split includes list output += opt.split(',').map(&:to_sym) if opt.present? # Remove resource type not included in 'can_include' output = serializer.can_include & output if serializer.respond_to?(:can_include) # Add 'always_include' resource type output += serializer.always_include if serializer.respond_to?(:always_include) output end def page opt = @opts[:page] opt.present? ? opt.to_i : 1 end def per_page opt = @opts[:per_page] return Kaminari.config.default_per_page if opt.nil? max_per_page = Kaminari.config.max_per_page.to_i opt = opt.to_i if max_per_page.zero? opt else opt > max_per_page ? max_per_page : opt end end def skip_paging @opts[:skip_paging].present? end end end end
Version data entries
5 entries across 5 versions & 1 rubygems