Class: Parse::User

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

Instance Attribute Summary

Attributes inherited from Object

#class_name, #created_at, #parse_object_id, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#as_json, #decrement, #increment, #new?, #parse_delete, #pointer, #refresh, #safe_json, #save, #to_json

Constructor Details

#initialize(data = nil) ⇒ User

Returns a new instance of User.



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

def initialize(data = nil)
  @class_name = Parse::Protocol::CLASS_USER
  
  #stringify symbol keys
  data["username"] = data[:username] if data[:username]
  data["password"] = data[:password] if data[:password]
  
  if data
    parse data
  end

  self
end

Class Method Details

.authenticate(username, password) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/parse/user.rb', line 9

def self.authenticate(username, password)
  body = {
    "username" => username,
    "password" => password
  }

  response = Parse.client.request(Parse::Protocol::USER_LOGIN_URI, :get, nil, body)
  
  new(response)
end

.reset_password(email) ⇒ Object



20
21
22
23
# File 'lib/parse/user.rb', line 20

def self.reset_password(email)
  body = {"email" => email}
  Parse.client.post(Parse::Protocol::PASSWORD_RESET_URI, body)
end

Instance Method Details

#uriObject



39
40
41
# File 'lib/parse/user.rb', line 39

def uri
  Protocol.user_uri @parse_object_id
end