Class: GitContacts::User
- Inherits:
-
Object
- Object
- GitContacts::User
- Defined in:
- lib/gitcontacts/User.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_contacts(gid) ⇒ Object
- #add_request(request_id) ⇒ Object
- #getcontacts ⇒ Object
-
#getemail ⇒ Object
def getname @obj.name.value if @obj end.
- #getinfo ⇒ Object
- #getpassword ⇒ Object
- #getrequests ⇒ Object
- #getuid ⇒ Object
-
#initialize(email) ⇒ User
constructor
A new instance of User.
- #password_correct?(sha) ⇒ Boolean
- #remove_contacts(gid) ⇒ Object
- #remove_request(request_id) ⇒ Object
- #set_password(sha) ⇒ Object
Constructor Details
#initialize(email) ⇒ User
Returns a new instance of User.
20 21 22 23 |
# File 'lib/gitcontacts/User.rb', line 20 def initialize email @email = email @obj = UserObject::access email end |
Class Method Details
.all ⇒ Object
16 17 18 |
# File 'lib/gitcontacts/User.rb', line 16 def self::all UserObject::all end |
.create(hash) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/gitcontacts/User.rb', line 9 def self::create hash # some keys are optional obj = UserObject.new obj.set_email hash[:email] obj.password = Digest::MD5.hexdigest(hash[:password]) end |
.exist?(email) ⇒ Boolean
5 6 7 |
# File 'lib/gitcontacts/User.rb', line 5 def self::exist? email UserObject::exist?(email) end |
Instance Method Details
#add_contacts(gid) ⇒ Object
67 68 69 |
# File 'lib/gitcontacts/User.rb', line 67 def add_contacts gid @obj.contacts << gid if @obj end |
#add_request(request_id) ⇒ Object
75 76 77 |
# File 'lib/gitcontacts/User.rb', line 75 def add_request request_id @obj.requests << request_id if @obj end |
#getcontacts ⇒ Object
42 43 44 |
# File 'lib/gitcontacts/User.rb', line 42 def getcontacts @obj.contacts.members if @obj end |
#getemail ⇒ Object
def getname
@obj.name.value if @obj
end
33 34 35 36 |
# File 'lib/gitcontacts/User.rb', line 33 def getemail #@obj.email if @obj @email end |
#getinfo ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/gitcontacts/User.rb', line 50 def getinfo { :uid => getuid, :email => getemail, :contacts => getcontacts, :request => getrequests } end |
#getpassword ⇒ Object
38 39 40 |
# File 'lib/gitcontacts/User.rb', line 38 def getpassword @obj.password.value if @obj end |
#getrequests ⇒ Object
46 47 48 |
# File 'lib/gitcontacts/User.rb', line 46 def getrequests @obj.requests.members if @obj end |
#getuid ⇒ Object
25 26 27 |
# File 'lib/gitcontacts/User.rb', line 25 def getuid getemail end |
#password_correct?(sha) ⇒ Boolean
59 60 61 |
# File 'lib/gitcontacts/User.rb', line 59 def password_correct? sha sha == getpassword && sha != nil && sha != "" end |
#remove_contacts(gid) ⇒ Object
71 72 73 |
# File 'lib/gitcontacts/User.rb', line 71 def remove_contacts gid @obj.contacts.delete gid if @obj end |
#remove_request(request_id) ⇒ Object
79 80 81 |
# File 'lib/gitcontacts/User.rb', line 79 def remove_request request_id @obj.requests.delete request_id if @obj end |
#set_password(sha) ⇒ Object
63 64 65 |
# File 'lib/gitcontacts/User.rb', line 63 def set_password sha @obj.password = sha if sha != nil && sha != "" end |