How do I can retrieve all user policies and scopes using Pundit Gem? I need to return a json object with all user policies to check permissions in Frontend javascript templates.
Using CanCanCan gem, I can do something like this:
class Ability
include CanCan::Ability
# ....
def to_list
rules.map do |rule|
object = { actions: rule.actions, subject: rule.subjects.map{ |s| s.is_a?(Symbol) ? s : s.name } }
object[:conditions] = rule.conditions unless rule.conditions.blank?
object[:inverted] = true unless rule.base_behavior
object
end
end
end
Is possible to do the same with Pundit?