Module: Sufia::User

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/sufia/user.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#abilityObject



72
73
74
# File 'app/models/concerns/sufia/user.rb', line 72

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



33
34
35
# File 'app/models/concerns/sufia/user.rb', line 33

def as_json(opts = nil)
  {id: user_key, text: display_name ? "#{display_name} (#{user_key})" : user_key}
end

#email_addressObject



37
38
39
# File 'app/models/concerns/sufia/user.rb', line 37

def email_address
  return self.email
end

#groupsObject

The basic groups method, override or will fallback to Sufia::Ldap::User



68
69
70
# File 'app/models/concerns/sufia/user.rb', line 68

def groups
  return self.group_list ? self.group_list.split(";?;") : []
end

#mailboxer_email(obj = nil) ⇒ Object

method needed for messaging



63
64
65
# File 'app/models/concerns/sufia/user.rb', line 63

def mailboxer_email(obj=nil)
  return nil
end

#nameObject



41
42
43
# File 'app/models/concerns/sufia/user.rb', line 41

def name
  return self.display_name.titleize || self.user_key rescue self.user_key
end

#to_paramObject

Redefine this for more intuitive keys in Redis



46
47
48
49
# File 'app/models/concerns/sufia/user.rb', line 46

def to_param
  # hack because rails doesn't like periods in urls.
  user_key.gsub(/\./, '-dot-')
end

#trophiesObject

method needed for trophies



52
53
54
55
# File 'app/models/concerns/sufia/user.rb', line 52

def trophies
  trophies = Trophy.where(:user_id => self.id)
  return trophies
end

#trophy_idsObject

method to get the trophy ids without the namespace included



58
59
60
# File 'app/models/concerns/sufia/user.rb', line 58

def trophy_ids
  trophies.map { |t| "#{Sufia.config.id_namespace}:#{t.generic_file_id}" }
end