# File lib/authpds/helpers/institution/current_institution_helper.rb, line 28 def primary_institution_from_ip unless request.nil? @primary_institution_from_ip ||= Institutions.with_ip(request.remote_ip).first end end
module Authpds::Helpers::Institution::CurrentInstitutionHelper
Public Instance Methods
current_primary_institution()
click to toggle source
Determine current primary institution based on:
0. institutions are not being used (returns nil) 1. institution query string parameter in URL 2. institution associated with the client IP 3. primary institution for the current user 4. first default institution
# File lib/authpds/helpers/institution/current_institution_helper.rb, line 14 def current_primary_institution @current_primary_institution ||= case when (institution_param.present? && all_institutions[institution_param]) all_institutions[institution_param] when primary_institution_from_ip.present? primary_institution_from_ip when (@current_user && current_user.primary_institution) current_user.primary_institution else Institutions.defaults.first end end
Private Instance Methods
all_institutions()
click to toggle source
All institutions
# File lib/authpds/helpers/institution/current_institution_helper.rb, line 37 def all_institutions @all_institutions ||= Institutions.institutions end
primary_institution_from_ip()
click to toggle source
Grab the first institution that matches the client IP