Module: GSGraph::Connections::Blocked

Included in:
Page
Defined in:
lib/gs_graph/connections/blocked.rb

Instance Method Summary collapse

Instance Method Details

#block!(*users) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gs_graph/connections/blocked.rb', line 18

def block!(*users)
  options = users.extract_options!
  blocked = post options.merge(
    :connection => :blocked,
    :uid => Array(users).flatten.collect(&:identifier).join(',')
  )
  blocked.delete_if do |user_id, succeeded|
    !succeeded
  end.keys.map! do |user_id|
    User.new user_id, :access_token => (options[:access_token] || self.access_token)
  end
end

#blocked(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/gs_graph/connections/blocked.rb', line 4

def blocked(options = {})
  blocked = self.connection :blocked, options
  blocked.map! do |user|
    User.new(user[:id], user.merge(
      :access_token => options[:access_token] || self.access_token
    ))
  end
end

#blocked?(user, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/gs_graph/connections/blocked.rb', line 13

def blocked?(user, options = {})
  blocked = self.connection :blocked, options.merge(:connection_scope => user.identifier)
  blocked.present?
end

#unblock!(user, options = {}) ⇒ Object



31
32
33
# File 'lib/gs_graph/connections/blocked.rb', line 31

def unblock!(user, options = {})
  delete options.merge(:connection => :blocked, :connection_scope => user.identifier)
end