lib/ahub/user.rb in ahub-0.2.0 vs lib/ahub/user.rb in ahub-0.3.1

- old
+ new

@@ -18,29 +18,25 @@ def self.find_by_username(username) matches = find_all(params: {q: username}) matches.find{|user| user.username.downcase.strip == username.downcase.strip} end - attr_reader :username, :realname, :avatar_url, - :post_count, :follow_count, :follower_count, - :active, :suspended, :deactivated, :answers - def initialize(attrs) - @id = attrs[:id] - @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] + super + @groups = attrs[:groups].map{|group| Ahub::Group.new(group)} if attrs[:groups] end def is_complete? !!@complete + end + + def questions + unless @questions + response = self.class.get_resource(url: "#{self.class.base_url}/#{id}/question.json", headers: self.class.admin_headers) + @questions = response[:list].map{ |question| Ahub::Question.new(question) } + end + + @questions end def answers unless @answers response = self.class.get_resource(url: "#{self.class.base_url}/#{id}/answer.json", headers: self.class.admin_headers)