Class: SimplyAuth::User

Inherits:
Model
  • Object
show all
Defined in:
app/models/simply_auth/user.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#attributes=, collection_path, #collection_path, create, #data, #data=, find, #initialize, instance_path, #instance_path, owner_class, path_component, #persisted=, #persisted?, #save

Constructor Details

This class inherits a constructor from SimplyAuth::Model

Instance Attribute Details

#emailObject

Returns the value of attribute email.



3
4
5
# File 'app/models/simply_auth/user.rb', line 3

def email
  @email
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'app/models/simply_auth/user.rb', line 3

def name
  @name
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'app/models/simply_auth/user.rb', line 3

def password
  @password
end

#user_pool_idObject

Returns the value of attribute user_pool_id.



3
4
5
# File 'app/models/simply_auth/user.rb', line 3

def user_pool_id
  @user_pool_id
end

Class Method Details

.all(ids) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'app/models/simply_auth/user.rb', line 30

def self.all(ids)
  response = RestClient.get(
    "https://api.simplyauth.com#{collection_path(ids)}",
    accept: :json
  )
  body = JSON.parse(response.body)[model_name.element.pluralize.camelize(:lower)]
  body.map do |data|
    data = data.deep_transform_keys { |key| key.to_s.underscore }
    new(data)
  end
end

.owner_class_nameObject



19
20
21
# File 'app/models/simply_auth/user.rb', line 19

def self.owner_class_name
  "UserPool"
end

Instance Method Details

#attributesObject



11
12
13
# File 'app/models/simply_auth/user.rb', line 11

def attributes
  super.merge(name: name, email: email, password: password)
end

#destroyObject



23
24
25
26
27
28
# File 'app/models/simply_auth/user.rb', line 23

def destroy
  response = RestClient.delete(
    "https://api.simplyauth.com#{instance_path}",
    accept: :json
  )
end

#owner_idObject



15
16
17
# File 'app/models/simply_auth/user.rb', line 15

def owner_id
  self.user_pool_id
end

#password_or_new_record?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'app/models/simply_auth/user.rb', line 7

def password_or_new_record?
  password || !persisted?
end