Class: Parse::User
Instance Attribute Summary
Attributes inherited from Object
#acl, #created_at, #obj_id, #updated_at
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Object
create, #create, #delete, #deleted?, find, #get_column, #method_missing, #new?, #parse_class_name, #parse_client, #save, #set_column, #to_s, #update, #updated?
Constructor Details
#initialize(username = nil, password = nil, hash = {}) ⇒ User
19
20
21
22
23
24
25
26
27
|
# File 'lib/parse/user.rb', line 19
def initialize username=nil, password=nil, hash={}
if username.is_a? Hash
super username
else
super hash
@username = username
@password = password
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Parse::Object
Class Method Details
.log_in(username, password) ⇒ Object
14
15
16
|
# File 'lib/parse/user.rb', line 14
def log_in username, password
self.new(username, password).log_in
end
|
.parse_class_name ⇒ Object
6
7
8
|
# File 'lib/parse/user.rb', line 6
def parse_class_name
'_User'
end
|
.sign_up(username, password, hash = {}) ⇒ Object
10
11
12
|
# File 'lib/parse/user.rb', line 10
def sign_up username, password, hash={}
self.new(username, password, hash).sign_up
end
|
Instance Method Details
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/parse/user.rb', line 40
def log_in
parse_client.log_in @username, @password do |resp_body|
@obj_id = resp_body['objectId']
@created_at = resp_body['createdAt']
@updated_at = resp_body['updatedAt']
@raw_hash.update(@updated_hash).update resp_body
@updated_hash.clear
parse_client.session_token = resp_body['sessionToken']
self
end
end
|
52
53
54
55
|
# File 'lib/parse/user.rb', line 52
def log_out
parse_client.log_out
self
end
|
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/parse/user.rb', line 29
def sign_up
parse_client.sign_up @username, @password, opts do |resp_body|
@obj_id = resp_body['objectId']
@created_at = resp_body['createdAt']
@raw_hash.update(@updated_hash).update resp_body
@updated_hash.clear
parse_client.session_token = resp_body['sessionToken']
self
end
end
|