Class: Parse::User
Instance Attribute Summary
Attributes inherited from Object
#acl, #created_at, #parse_object_id, #updated_at
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Object
count, count!, #create, create, #create!, #delete, #delete!, #deleted?, find, find!, find_all, find_all!, find_by_id, find_by_id!, #get_column, #method_missing, #new?, #parse_class_name, #parse_client, #pointer, register_parse_class, reserved_column?, reserved_columns, #save, #save!, #set_column, #to_h, #to_json, #to_s, #update, #update!, #updated?
Methods included from Util
#string_keyed_hash
Constructor Details
#initialize(username = nil, password = nil, hash = {}) ⇒ User
Returns a new instance of User.
23
24
25
26
27
28
29
30
31
|
# File 'lib/parse/user.rb', line 23
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
|
.request_password_reset(email) ⇒ Object
18
19
20
|
# File 'lib/parse/user.rb', line 18
def request_password_reset email
Parse::Client.default.call_api :post, 'requestPasswordReset', "email" => email
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
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/parse/user.rb', line 44
def log_in
parse_client.log_in @username, @password do |resp_body|
@parse_object_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
|
56
57
58
59
|
# File 'lib/parse/user.rb', line 56
def log_out
parse_client.log_out
self
end
|
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/parse/user.rb', line 33
def sign_up
parse_client.sign_up @username, @password, opts do |resp_body|
@parse_object_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
|