Class: Seedy::Users

Inherits:
Record show all
Defined in:
lib/seedy/records/users.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#initialize, #inspect, #to_s, #to_sql

Constructor Details

This class inherits a constructor from Seedy::Record

Class Method Details

.build(offset) ⇒ Object



29
30
31
32
33
# File 'lib/seedy/records/users.rb', line 29

def build(offset)
  user = Users.new
  user.update_attributes(offset)
  user
end

Instance Method Details

#set_user_name(offset) ⇒ Object



42
43
44
45
# File 'lib/seedy/records/users.rb', line 42

def set_user_name(offset)
  return "user#{offset}" if offset
  (@attributes[:first_name][0,1] + @attributes[:last_name][0,6]).downcase
end

#update_attributes(offset) ⇒ Object



36
37
38
39
40
# File 'lib/seedy/records/users.rb', line 36

def update_attributes(offset)
  write_attribute(:user_name, set_user_name(offset))
  write_attribute(:sugar_login, 0)
  write_attribute(:user_hash, OpenSSL::Digest::MD5.new("#{offset}")) if offset
end