Module: Authpds::Controllers::AuthpdsController::InstitutionAttributes
- Defined in:
- lib/authpds/controllers/authpds_controller/institution_attributes.rb
Class Method Summary collapse
-
.included(klass) ⇒ Object
Set helper methods when this module is included.
Instance Method Summary collapse
-
#current_primary_institution ⇒ Object
Determine current primary institution based on: 0.
-
#url_for(options = {}) ⇒ Object
Override Rails ActionController#url_for to add institution.
Class Method Details
.included(klass) ⇒ Object
Set helper methods when this module is included.
8 9 10 11 12 |
# File 'lib/authpds/controllers/authpds_controller/institution_attributes.rb', line 8 def self.included(klass) klass.class_eval do helper_method :current_primary_institution end end |
Instance Method Details
#current_primary_institution ⇒ Object
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
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/authpds/controllers/authpds_controller/institution_attributes.rb', line 20 def current_primary_institution @current_primary_institution ||= (institution_param.nil? or all_institutions[institution_param].nil?) ? ((primary_institution_from_ip.nil?) ? ((@current_user.nil? or current_user.primary_institution.nil?) ? Institutions.defaults.first : current_user.primary_institution) : primary_institution_from_ip) : all_institutions[institution_param] end |
#url_for(options = {}) ⇒ Object
Override Rails ActionController#url_for to add institution.
32 33 34 35 |
# File 'lib/authpds/controllers/authpds_controller/institution_attributes.rb', line 32 def url_for(={}) [institution_param_key] ||= institution_param unless institution_param.nil? super end |