Module: Authpds::ActsAsAuthentic::InstitutionAttributes
- Defined in:
- lib/authpds/acts_as_authentic/institutions_attributes.rb
Instance Method Summary collapse
- #institutions ⇒ Object
- #institutions=(new_institutions) ⇒ Object
- #primary_institution ⇒ Object
- #primary_institution=(new_primary_institution) ⇒ Object
Instance Method Details
#institutions ⇒ Object
15 16 17 |
# File 'lib/authpds/acts_as_authentic/institutions_attributes.rb', line 15 def institutions user_attributes[:institutions].collect { |institution| all_institutions[institution] } unless user_attributes.nil? end |
#institutions=(new_institutions) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/authpds/acts_as_authentic/institutions_attributes.rb', line 19 def institutions=(new_institutions) raise ArgumentError.new("Institutions input should be an array.") unless new_institutions.is_a?(Array) new_institutions.collect! { |institution| institution.to_sym } new_institutions = new_institutions.select { |institution| all_institutions[ new_institutions.is_a?(Institutions::Institution) ? institution.code : institution.to_sym] } self.user_attributes=({:institutions => new_institutions}) unless new_institutions.empty? end |
#primary_institution ⇒ Object
6 7 8 |
# File 'lib/authpds/acts_as_authentic/institutions_attributes.rb', line 6 def primary_institution all_institutions[user_attributes[:primary_institution]] unless user_attributes.nil? end |
#primary_institution=(new_primary_institution) ⇒ Object
10 11 12 13 |
# File 'lib/authpds/acts_as_authentic/institutions_attributes.rb', line 10 def primary_institution=(new_primary_institution) new_primary_institution = new_primary_institution.code if new_primary_institution.is_a?(Institutions::Institution) self.user_attributes=({:primary_institution => new_primary_institution.to_sym}) unless new_primary_institution.nil? end |