Class: Joey::User
- Includes:
- ParserHelpers
- Defined in:
- lib/joey/user.rb
Instance Attribute Summary
Attributes inherited from Model
Class Method Summary collapse
Instance Method Summary collapse
- #friends!(ids) ⇒ Object
- #has_app_permission?(ext_perm) ⇒ Boolean
- #info(args) ⇒ Object
- #valid? ⇒ Boolean
- #validate ⇒ Object
Methods included from ParserHelpers
Methods inherited from Profile
Methods inherited from Model
define_properties, find, get_all, has_association, hash_populating_accessor, hash_populating_association, #initialize
Constructor Details
This class inherits a constructor from Joey::Model
Class Method Details
.recognize?(hash) ⇒ Boolean
16 17 18 |
# File 'lib/joey/user.rb', line 16 def self.recognize?(hash) !hash.has_key?("category") end |
Instance Method Details
#friends!(ids) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/joey/user.rb', line 49 def friends!(ids) data = self.client.rest_call('users.getInfo', :uids => ids, :fields => 'about_me,activities,affiliations,books,birthday,birthday_date,current_location,education_history, email,family,first_name,hometown_location,hs_info,interests,is_app_user,is_blocked,last_name, locale,meeting_for,meeting_sex,movies,music,name,notes_count,pic,pic_big,pic_small,pic_square, pic_with_logo,pic_big_with_logo,pic_small_with_logo,pic_square_with_logo, political,profile_blurb,profile_update_time,profile_url,quotes,relationship_status,religion,sex, significant_other_id,status,timezone,tv,username,wall_count,website,work_history') self.client.map_data(data, self.class) end |
#has_app_permission?(ext_perm) ⇒ Boolean
44 45 46 47 |
# File 'lib/joey/user.rb', line 44 def (ext_perm) = client.get_object('me/permissions', {})['data'].first boolianize([ext_perm]) end |
#info(args) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/joey/user.rb', line 60 def info(args) data = self.client.rest_call('users.getInfo', :uids => self.id, :fields => args.join(',')) user = self.client.map_data(data, self.class).first user.id = self.id user end |
#valid? ⇒ Boolean
77 78 79 80 81 |
# File 'lib/joey/user.rb', line 77 def valid? self.validate puts self.errors.inspect unless self.errors.empty? self.errors.empty? end |
#validate ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/joey/user.rb', line 67 def validate errors << { :message => 'id should not be nil' } if id.nil? errors << { :message => "name should be string but is #{name.inspect}" } unless name.is_a?(String) errors << { :message => "gender should be 'male' or 'female' but is #{gender.inspect}" } unless ['male', 'female', nil].include?(gender) errors << { :message => "pic big is neither string nor nil but is #{pic_big.inspect}" } unless pic_big.is_a?(String) || pic_big.nil? errors << { :message => "current location is neither Joey::Location nor nil but is #{current_location.inspect}" } unless current_location.is_a?(Joey::Location) || current_location.nil? errors << { :message => "Facebook is an idiot. This is an event instead of a Joey::User or Joey::Page" } unless start_time.nil? # updated_time.to_time rescue errors << { :message => 'updated_time is not compatible' } end |