Class: Parse::User

Inherits:
Object show all
Defined in:
lib/parse/user.rb

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  username, password
  self.new(username, password).
end

.parse_class_nameObject



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  username, password, hash={}
  self.new(username, password, hash).
end

Instance Method Details

#log_inObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/parse/user.rb', line 44

def 
  parse_client. @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

#log_outObject



56
57
58
59
# File 'lib/parse/user.rb', line 56

def log_out
  parse_client.log_out
  self
end

#sign_upObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/parse/user.rb', line 33

def 
  parse_client. @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