Module: FbGraph::Connections::Permissions

Included in:
User
Defined in:
lib/fb_graph/connections/permissions.rb

Instance Method Summary collapse

Instance Method Details

#permissions(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fb_graph/connections/permissions.rb', line 4

def permissions(options = {})
  self.connection(:permissions, options).try(:inject, []) do |arr, entry|
    if entry.include? :status
      # v2.0
      arr << entry[:permission].to_sym if entry[:status] == 'granted'
    else
      # v1.0
      entry.each do |key, value|
        arr << key.to_sym if value.to_i == 1
      end
    end
    arr
  end || []
end

#revoke!(permission = nil, options = {}) ⇒ Object



19
20
21
# File 'lib/fb_graph/connections/permissions.rb', line 19

def revoke!(permission = nil, options = {})
  destroy options.merge(:permission => permission, :connection => :permissions)
end