Sha256: 9daaca533389a6ad73b2ee9fe49c9e5dc0a6d51715d5ac960ef906092612f3da
Contents?: true
Size: 836 Bytes
Versions: 8
Compression:
Stored size: 836 Bytes
Contents
# frozen_string_literal: true require 'pundit' module Ditty module Helpers module Pundit include ::Pundit def authorize(record, query) query = :"#{query}?" unless query[-1] == '?' super end def permitted_attributes(record, action) param_key = PolicyFinder.new(record).param_key policy = policy(record) method_name = if policy.respond_to?("permitted_attributes_for_#{action}") "permitted_attributes_for_#{action}" else 'permitted_attributes' end request.params.fetch(param_key, {}).select do |key, _value| policy.public_send(method_name).include? key.to_sym end end def pundit_user current_user end end end end
Version data entries
8 entries across 8 versions & 1 rubygems