Class: Parse::User

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

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, #create!, #delete, #delete!, #deleted?, find, find!, #get_column, #method_missing, #new?, #parse_class_name, #parse_client, #save, #save!, #set_column, #to_s, #update, #update!, #updated?

Constructor Details

#initialize(username = nil, password = nil, hash = {}) ⇒ User

Returns a new instance of 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  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

.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



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/parse/user.rb', line 40

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

#log_outObject



52
53
54
55
# File 'lib/parse/user.rb', line 52

def log_out
  parse_client.log_out
  self
end

#sign_upObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/parse/user.rb', line 29

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