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 resources_with_permission(relation_name, action: :view, all_columns: true, include_actions: []) policy(Recurso::Global.instance).resources_with_permission( relation_name, action: action, all_columns: all_columns, include_actions: include_actions ) end def policy_class Recurso::BasePolicy end end end