class Wallaby::Her::PunditProvider

Pundit provider for Her

Public Instance Methods

accessible_for(_action, scope) click to toggle source

Find out the class and filter scope. @param _action [Symbol, String] @param scope [Object] @return [Object]

# File lib/adapters/wallaby/her/pundit_provider.rb, line 11
def accessible_for(_action, scope)
  klass =
    if scope.is_a? ::Her::Model::Relation
      scope.instance_variable_get :@parent
    else
      scope
    end
  scope_policy = Pundit::PolicyFinder.new(klass).scope
  scope_policy ? scope_policy.new(user, scope).resolve : scope
end