Module: Sufia::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/sufia/models/user.rb
Overview
Copyright © 2012 The Pennsylvania State University
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #ability ⇒ Object
-
#as_json(opts = nil) ⇒ Object
Format the json for select2 which requires just an id and a field called text.
- #email_address ⇒ Object
-
#groups ⇒ Object
The basic groups method, override or will fallback to Sufia::Ldap::User.
-
#mailboxer_email(obj = nil) ⇒ Object
method needed for messaging.
- #name ⇒ Object
-
#to_param ⇒ Object
Redefine this for more intuitive keys in Redis.
-
#trophies ⇒ Object
method needed for trophies.
-
#trophy_ids ⇒ Object
method to get the trophy ids without the namespace included.
Instance Method Details
#ability ⇒ Object
87 88 89 |
# File 'lib/sufia/models/user.rb', line 87 def ability @ability ||= Ability.new(self) end |
#as_json(opts = nil) ⇒ Object
Format the json for select2 which requires just an id and a field called text. If we need an alternate format we should probably look at a json template gem
48 49 50 |
# File 'lib/sufia/models/user.rb', line 48 def as_json(opts = nil) {id: user_key, text: display_name ? "#{display_name} (#{user_key})" : user_key} end |
#email_address ⇒ Object
52 53 54 |
# File 'lib/sufia/models/user.rb', line 52 def email_address return self.email end |
#groups ⇒ Object
The basic groups method, override or will fallback to Sufia::Ldap::User
83 84 85 |
# File 'lib/sufia/models/user.rb', line 83 def groups return self.group_list ? self.group_list.split(";?;") : [] end |
#mailboxer_email(obj = nil) ⇒ Object
method needed for messaging
78 79 80 |
# File 'lib/sufia/models/user.rb', line 78 def mailboxer_email(obj=nil) return nil end |
#name ⇒ Object
56 57 58 |
# File 'lib/sufia/models/user.rb', line 56 def name return self.display_name.titleize || self.user_key rescue self.user_key end |
#to_param ⇒ Object
Redefine this for more intuitive keys in Redis
61 62 63 64 |
# File 'lib/sufia/models/user.rb', line 61 def to_param # hack because rails doesn't like periods in urls. user_key.gsub(/\./, '-dot-') end |
#trophies ⇒ Object
method needed for trophies
67 68 69 70 |
# File 'lib/sufia/models/user.rb', line 67 def trophies trophies = Trophy.where(:user_id => self.id) return trophies end |