Methods
R
Instance Public methods
resolve()

rubocop:todo Metrics/MethodLength

    # File rhino/rhino/app/policies/rhino/crud_policy.rb
 74 def resolve # rubocop:disable Metrics/AbcSize,
 75   role_scopes = []
 76 
 77   # Get every role for the auth owner
 78   Rhino.base_owner.roles_for_auth(auth_owner).each do |role, base_owner_array|
 79     base_owner_array.each do |base_owner|
 80       scope_class = Rhino::PolicyHelper.find_policy_scope(role, scope)
 81       next unless scope_class
 82 
 83       # Collect all the role based scopes
 84       # Use the scope for this role and join/select the base owner
 85       scope_instance = scope_class.new(auth_owner, scope)
 86       # NUB-367 and NUB-392
 87       # default scopes with includes and order can cause problems
 88       scope_instance = scope_instance.resolve.unscope(:includes, :order)
 89       role_scopes << scope_instance.select(tnpk(scope)).joins(scope.joins_for_base_owner).where(tnpk(Rhino.base_owner) => base_owner.id)
 90     end
 91   end
 92 
 93   # Select with present? because scope.none with produce empty sql string
 94   role_scopes = role_scopes.map(&:to_sql).compact_blank
 95   return scope.none unless role_scopes.present?
 96 
 97   # UNION all the role based scopes
 98   # The front end needs to filter per base owner as appropriate
 99   scope.where("#{tnpk(scope)} in (#{role_scopes.join(' UNION ')})")
100 end