1 # frozen_string_literal: true
4 include CanCan::Ability
6 def initialize(user, token)
8 can [:read, :read_one], UserPreference if capability?(token, :allow_read_prefs)
9 can [:update, :update_one, :delete_one], UserPreference if capability?(token, :allow_write_prefs)
15 def capability?(token, cap)
16 token&.read_attribute(cap)