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 13 |
# File 'lib/authpds/controllers/authpds_controller/institution_attributes.rb', line 8 def self.included(klass) klass.class_eval do helper_method :current_primary_institution helper_method :url_for 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
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/authpds/controllers/authpds_controller/institution_attributes.rb', line 21 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.
33 34 35 36 37 38 |
# File 'lib/authpds/controllers/authpds_controller/institution_attributes.rb', line 33 def url_for(={}) if institution_param.present? and .is_a? Hash [institution_param_key] ||= institution_param end super end |