Module: Sufia::User::ClassMethods

Defined in:
app/models/concerns/sufia/user.rb

Instance Method Summary collapse

Instance Method Details

#audituserObject

Override this method if you aren’t using email/password



148
149
150
# File 'app/models/concerns/sufia/user.rb', line 148

def audituser
  User.find_by_user_key(audituser_key) || User.create!(Devise.authentication_keys.first => audituser_key, password: Devise.friendly_token[0, 20])
end

#audituser_keyObject

Override this method if you aren’t using email as the userkey



153
154
155
# File 'app/models/concerns/sufia/user.rb', line 153

def audituser_key
  '[email protected]'
end

#batchuserObject

Override this method if you aren’t using email/password



158
159
160
# File 'app/models/concerns/sufia/user.rb', line 158

def batchuser
  User.find_by_user_key(batchuser_key) || User.create!(Devise.authentication_keys.first => batchuser_key, password: Devise.friendly_token[0, 20])
end

#batchuser_keyObject

Override this method if you aren’t using email as the userkey



163
164
165
# File 'app/models/concerns/sufia/user.rb', line 163

def batchuser_key
  '[email protected]'
end

#currentObject



139
140
141
# File 'app/models/concerns/sufia/user.rb', line 139

def current
  Thread.current[:user]
end

#current=(user) ⇒ Object



143
144
145
# File 'app/models/concerns/sufia/user.rb', line 143

def current=(user)
  Thread.current[:user] = user
end

#from_url_component(component) ⇒ Object



167
168
169
# File 'app/models/concerns/sufia/user.rb', line 167

def from_url_component(component)
  User.find_by_user_key(component.gsub(/-dot-/, '.'))
end

#recent_users(start_date, end_date = nil) ⇒ Object



171
172
173
174
# File 'app/models/concerns/sufia/user.rb', line 171

def recent_users(start_date, end_date = nil)
  end_date ||= DateTime.now # doing or eq here so that if the user passes nil we still get now
  User.where(created_at: start_date..end_date)
end