Class: SimplyAuth::User
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#user_pool_id ⇒ Object
Returns the value of attribute user_pool_id.
Attributes inherited from Model
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
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'app/models/simply_auth/user.rb', line 3 def email @email end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'app/models/simply_auth/user.rb', line 3 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'app/models/simply_auth/user.rb', line 3 def password @password end |
#user_pool_id ⇒ Object
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_name ⇒ Object
19 20 21 |
# File 'app/models/simply_auth/user.rb', line 19 def self.owner_class_name "UserPool" end |
Instance Method Details
#attributes ⇒ Object
11 12 13 |
# File 'app/models/simply_auth/user.rb', line 11 def attributes super.merge(name: name, email: email, password: password) end |
#destroy ⇒ Object
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_id ⇒ Object
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
7 8 9 |
# File 'app/models/simply_auth/user.rb', line 7 def password_or_new_record? password || !persisted? end |