Module: Sufia::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/sufia/user.rb
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
69 70 71 |
# File 'app/models/concerns/sufia/user.rb', line 69 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
30 31 32 |
# File 'app/models/concerns/sufia/user.rb', line 30 def as_json(opts = nil) {id: user_key, text: display_name ? "#{display_name} (#{user_key})" : user_key} end |
#email_address ⇒ Object
34 35 36 |
# File 'app/models/concerns/sufia/user.rb', line 34 def email_address return self.email end |
#groups ⇒ Object
The basic groups method, override or will fallback to Sufia::Ldap::User
65 66 67 |
# File 'app/models/concerns/sufia/user.rb', line 65 def groups @groups ||= self.group_list ? self.group_list.split(";?;") : [] end |
#mailboxer_email(obj = nil) ⇒ Object
method needed for messaging
60 61 62 |
# File 'app/models/concerns/sufia/user.rb', line 60 def mailboxer_email(obj=nil) return nil end |
#name ⇒ Object
38 39 40 |
# File 'app/models/concerns/sufia/user.rb', line 38 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
43 44 45 46 |
# File 'app/models/concerns/sufia/user.rb', line 43 def to_param # hack because rails doesn't like periods in urls. user_key.gsub(/\./, '-dot-') end |
#trophies ⇒ Object
method needed for trophies
49 50 51 52 |
# File 'app/models/concerns/sufia/user.rb', line 49 def trophies trophies = Trophy.where(:user_id => self.id) return trophies end |