Module: DataMapper::Is::Parse

Defined in:
lib/is/parse.rb

Instance Method Summary collapse

Instance Method Details

#is_parse(options = {}) ⇒ Object



5
6
7
8
9
# File 'lib/is/parse.rb', line 5

def is_parse(options = {})
  property :id, Property::ParseKey
  property :created_at, Property::ParseDate, field: "createdAt"
  property :updated_at, Property::ParseDate, field: "updatedAt"
end

#is_parse_user(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/is/parse.rb', line 11

def is_parse_user(options = {})
  is_parse(options)

  storage_names[:default] = "_User"

  property :username, Property::String, unique: true
  property :password, Property::String
  property :email,    Property::String, format: :email_address

  class << self
    # Authenticate a user
    #
    # @param [String] username
    #   username
    #
    # @param [String] password
    #   password
    #
    # @return [Resource, nil]
    #   the user resource, or nil if authentication failed
    #
    # @api semipublic
    def authenticate(username, password)
      result = repository.adapter.(username, password)
      get(result["objectId"])
    rescue ::Parse::ParseError
      nil
    end

    def request_password_reset(email)
      repository.adapter.request_password_reset email
    end
  end
end