Class: User

Inherits:
Object
  • Object
show all
Includes:
ArAdapter, DmAdapter, MmAdapter, MongoidAdapter, SequelAdapter, TcAdapter
Defined in:
lib/models/abstract_user.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ArAdapter

included

Methods included from MongoidAdapter

included

Methods included from SequelAdapter

included

Methods included from MmAdapter

included

Methods included from TcAdapter

included

Methods included from DmAdapter

included

Constructor Details

#initialize(interfacing_class_instance) ⇒ User

Returns a new instance of User.



39
40
41
# File 'lib/models/abstract_user.rb', line 39

def initialize(interfacing_class_instance)
  @instance = interfacing_class_instance
end

Class Method Details

.authenticate(name, pass) ⇒ Object



47
48
49
50
51
52
# File 'lib/models/abstract_user.rb', line 47

def self.authenticate(name, pass)
  current_user = get(:name => name)
  return nil if current_user.nil?
  return current_user if User.encrypt(pass, current_user.salt) == current_user.hashed_password
  nil
end

Instance Method Details

#db_instanceObject



54
55
56
# File 'lib/models/abstract_user.rb', line 54

def db_instance
  @instance
end

#idObject



43
44
45
# File 'lib/models/abstract_user.rb', line 43

def id
  @instance.id
end