module Recurso module Identity def self.included(base) base.has_many :permissions, dependent: :destroy, class_name: Recurso::Config.instance.permission_class_name_for(base), foreign_key: Recurso::Config.instance.identity_foreign_key_for(base) end def policy(resource = self) (resource&.policy_class || Recurso::NilClassPolicy).new(self, resource) end def policy_class Recurso::BasePolicy end end end