Class: Ahub::User
- Inherits:
-
Object
- Object
- Ahub::User
- Extended by:
- APIHelpers
- Includes:
- ClassHelpers
- Defined in:
- lib/ahub/user.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#avatar_url ⇒ Object
readonly
Returns the value of attribute avatar_url.
-
#deactivated ⇒ Object
readonly
Returns the value of attribute deactivated.
-
#follow_count ⇒ Object
readonly
Returns the value of attribute follow_count.
-
#follower_count ⇒ Object
readonly
Returns the value of attribute follower_count.
-
#post_count ⇒ Object
readonly
Returns the value of attribute post_count.
-
#realname ⇒ Object
readonly
Returns the value of attribute realname.
-
#suspended ⇒ Object
readonly
Returns the value of attribute suspended.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ User
constructor
A new instance of User.
- #is_complete? ⇒ Boolean
Methods included from APIHelpers
admin_headers, base_url, find, find_all, headers, object_id_from_response
Methods included from ClassHelpers
Constructor Details
#initialize(attrs) ⇒ User
Returns a new instance of User.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ahub/user.rb', line 28 def initialize(attrs) @username = attrs[:username] @realname = attrs[:realname] @avatar_url = attrs[:avatar] @post_count = attrs[:postCount] @follow_count = attrs[:followCount] @follower_count = attrs[:followerCount] @active = attrs[:active] @suspended = attrs[:suspended] @deactivated =attrs[:deactivated] @complete = attrs[:complete] end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def active @active end |
#avatar_url ⇒ Object (readonly)
Returns the value of attribute avatar_url.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def avatar_url @avatar_url end |
#deactivated ⇒ Object (readonly)
Returns the value of attribute deactivated.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def deactivated @deactivated end |
#follow_count ⇒ Object (readonly)
Returns the value of attribute follow_count.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def follow_count @follow_count end |
#follower_count ⇒ Object (readonly)
Returns the value of attribute follower_count.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def follower_count @follower_count end |
#post_count ⇒ Object (readonly)
Returns the value of attribute post_count.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def post_count @post_count end |
#realname ⇒ Object (readonly)
Returns the value of attribute realname.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def realname @realname end |
#suspended ⇒ Object (readonly)
Returns the value of attribute suspended.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def suspended @suspended end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
24 25 26 |
# File 'lib/ahub/user.rb', line 24 def username @username end |
Class Method Details
.create(username:, email:, password: nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ahub/user.rb', line 6 def self.create(username:, email:, password:nil) url = "#{base_url}.json" payload = { email: email, username: username, password: password || Ahub::DEFAULT_PASSWORD, } response = RestClient.post(url, payload, admin_headers) find(object_id_from_response(response)) end |
.find_by_username(username) ⇒ Object
19 20 21 22 |
# File 'lib/ahub/user.rb', line 19 def self.find_by_username(username) matches = find_all(params: {q: username}) matches.find{|user| user.username.downcase.strip == username.downcase.strip} end |
Instance Method Details
#is_complete? ⇒ Boolean
41 42 43 |
# File 'lib/ahub/user.rb', line 41 def is_complete? !!@complete end |