Sha256: 0b7e0f7aed0f4728157d0aaf0e1f03cd2ccd49cde695988f5ed1c615f6a0ce3c
Contents?: true
Size: 749 Bytes
Versions: 8
Compression:
Stored size: 749 Bytes
Contents
module JsonapiCompliable module Util class IncludeParams def self.compare(includes, whitelist) {}.tap do |valid| includes.to_hash.each_pair do |key, sub_hash| if whitelist[key] valid[key] = compare(sub_hash, whitelist[key]) end end end end def self.scrub(controller) dsl = controller._jsonapi_compliable whitelist = dsl.sideloads[:whitelist] || {} whitelist = whitelist[controller.action_name] includes = JSONAPI::IncludeDirective.new(controller.params[:include]) if whitelist Util::IncludeParams.compare(includes, whitelist) else {} end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems