Sha256: 1cecc40aff8c0c3db5661b6ebf969437dc235169f8a72280a18ba68afd3d4502
Contents?: true
Size: 700 Bytes
Versions: 8
Compression:
Stored size: 700 Bytes
Contents
module JSONAPI # Inclusion and sparse fields support module Fetching private # Extracts and formats sparse fieldsets # # Ex.: `GET /resource?fields[relationship]=id,created_at` # # @return [Hash] def jsonapi_fields ActiveSupport::HashWithIndifferentAccess.new.tap do |h| (params[:fields] || []).each do |k, v| h[k] = v.split(',').map(&:strip).compact end end end # Extracts and whitelists allowed includes # # Ex.: `GET /resource?include=relationship,relationship.subrelationship` # # @return [Array] def jsonapi_include params['include'].to_s.split(',').map(&:strip).compact end end end
Version data entries
8 entries across 8 versions & 1 rubygems