codeforamerica/ohana-api

View on GitHub
app/policies/organization_policy.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class OrganizationPolicy < ApplicationPolicy
  class Scope < Scope
    def resolve
      return scope.pluck(:id, :name, :slug).sort_by(&:second) if user.super_admin?

      scope.with_locations(location_ids).pluck(:id, :name, :slug)
    end
  end
end