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
- #getname ⇒ 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.
19 20 21 |
# File 'lib/gitcontacts/User.rb', line 19 def initialize email @obj = UserObject::access email end |
Class Method Details
.create(hash) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/gitcontacts/User.rb', line 9 def self::create hash # some keys are optional if hash.keys.include?(:email) && hash.keys.include?(:password) && !User::exist?(hash[:email]) obj = UserObject.new obj.email = hash[:email] obj.password = hash[:password] obj.uid end end |
.exist?(email) ⇒ Boolean
5 6 7 |
# File 'lib/gitcontacts/User.rb', line 5 def self::exist? email true if UserObject::exist?(email) end |
Instance Method Details
#add_contacts(gid) ⇒ Object
55 56 57 |
# File 'lib/gitcontacts/User.rb', line 55 def add_contacts gid @obj.contacts << gid if @obj end |
#add_request(request_id) ⇒ Object
63 64 65 |
# File 'lib/gitcontacts/User.rb', line 63 def add_request request_id @obj.requests << request_id if @obj end |
#getcontacts ⇒ Object
39 40 41 |
# File 'lib/gitcontacts/User.rb', line 39 def getcontacts @obj.contacts if @obj end |
#getemail ⇒ Object
31 32 33 |
# File 'lib/gitcontacts/User.rb', line 31 def getemail @obj.email if @obj end |
#getname ⇒ Object
27 28 29 |
# File 'lib/gitcontacts/User.rb', line 27 def getname @obj.name if @obj end |
#getpassword ⇒ Object
35 36 37 |
# File 'lib/gitcontacts/User.rb', line 35 def getpassword @obj.password if @obj end |
#getrequests ⇒ Object
43 44 45 |
# File 'lib/gitcontacts/User.rb', line 43 def getrequests @obj.requests if @obj end |
#getuid ⇒ Object
23 24 25 |
# File 'lib/gitcontacts/User.rb', line 23 def getuid @obj.uid if @obj end |
#password_correct?(sha) ⇒ Boolean
47 48 49 |
# File 'lib/gitcontacts/User.rb', line 47 def password_correct? sha sha == getpassword && sha != nil && sha != "" end |
#remove_contacts(gid) ⇒ Object
59 60 61 |
# File 'lib/gitcontacts/User.rb', line 59 def remove_contacts gid @obj.contacts.delete gid if @obj end |
#remove_request(request_id) ⇒ Object
67 68 69 |
# File 'lib/gitcontacts/User.rb', line 67 def remove_request request_id @obj.requests.delete request_id if @obj end |
#set_password(sha) ⇒ Object
51 52 53 |
# File 'lib/gitcontacts/User.rb', line 51 def set_password sha @obj.password = sha if sha != nil && sha != "" end |