1st way
The Pundit policy is pure ruby code, so if you do not want to store the code inside the database and evaluate it dynamically, I would say that the answer is no. It's not safe. However, you can give him pleasure.
Second way
But nothing prevents you from creating a model that stores the rules in plain json and compares them using Pundit, for example:
class PostPolicy < ApplicationPolicy
def update?
access_setting = PolicySetting.find_by(key: self.class_name)
user.role.in?(access_setting['roles'])
end
end
, .
. , ( , ) .
4-
DSL
5-
- json-logic-ruby