Class: Mogli::User

Inherits:
Profile show all
Defined in:
lib/mogli/user.rb

Direct Known Subclasses

TestUser

Defined Under Namespace

Classes: UnrecognizedExtendedPermissionException

Constant Summary

ALL_EXTENDED_PERMISSIONS =

the entire list of extended permissions the user is able to grant the application. the list should be kept in sync with developers.facebook.com/docs/authentication/permissions

[
  # timeline
  :publish_actions,

  # publishing permissions
  :publish_stream,
  :create_event,
  :rsvp_event,
  :offline_access,
  :publish_checkins,

  # data permissions
  :user_about_me,
  :user_activities,
  :user_birthday,
  :user_education_history,
  :user_events,
  :user_groups,
  :user_hometown,
  :user_interests,
  :user_likes,
  :user_location,
  :user_notes,
  :user_online_presence,
  :user_photo_video_tags,
  :user_photos,
  :user_relationships,
  :user_relationship_details,
  :user_religion_politics,
  :user_status,
  :user_videos,
  :user_website,
  :user_work_history,
  :email,
  :read_friendlists,
  :read_insights,
  :read_mailbox,
  :read_requests,
  :read_stream,
  :xmpp_login,
  :ads_management,
  :user_checkins,
  :friends_likes,
  :friends_birthday,
  :friends_location,
  :friends_relationships,

  # page permissions
  :manage_pages
]

Instance Attribute Summary collapse

Attributes inherited from Model

#type

Attributes included from Model::Search

#search_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Profile

#image_url, #large_image_url, #normal_image_url, #sized_image_url, #small_image_url, #square_image_url, #to_s

Methods inherited from Model

#==, add_creation_method, #client, #client=, creation_keys, creation_properties, define_properties, #destroy, #fetch, find, fql_mapping, has_association, hash_populating_accessor, hash_populating_accessor_with_default_field, included, #initialize, #merge!, #method_missing, #post_params, property, #warn_about_invalid_property

Methods included from Model::Search

#search

Constructor Details

This class inherits a constructor from Mogli::Model

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Mogli::Model

Instance Attribute Details

#extended_permissionsObject (readonly)

Returns the value of attribute extended_permissions



40
41
42
# File 'lib/mogli/user.rb', line 40

def extended_permissions
  @extended_permissions
end

Class Method Details

.recognize?(hash) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/mogli/user.rb', line 10

def self.recognize?(hash)
  !hash.has_key?("category")
end

Instance Method Details

#has_permission?(permission) ⇒ Boolean

check if the facebook user has a specific permission. the permission arg is a symbol matching the facebook extended permission names exactly: developers.facebook.com/docs/authentication/permissions

Returns:

  • (Boolean)


102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/mogli/user.rb', line 102

def has_permission?(permission)
  if !ALL_EXTENDED_PERMISSIONS.include? permission
    raise UnrecognizedExtendedPermissionException,
          "The requested permission is not recognized as a facebook extended permission: '#{permission}'"
  end

  if !defined?(@extended_permissions)
    fetch_permissions
  end

  extended_permissions[permission]
end

#revoke_permissionObject

revoke all permissions for this user



116
117
118
# File 'lib/mogli/user.rb', line 116

def revoke_permission
  client.delete("#{id}/permissions")
end