Class: DeviseFacebookOpenGraph::Facebook::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/devise_facebook_open_graph/facebook/session.rb

Constant Summary collapse

FACEBOOK_SESSION_KEYS =

Keys found in cookie content. We are supplying reader methods for these values which are read from cookie content

%w(session_key expires uid sig secret access_token)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cookies) ⇒ Session

Creates a new Facebook session based cookies hash from a request



22
23
24
# File 'lib/devise_facebook_open_graph/facebook/session.rb', line 22

def initialize(cookies)
  @cookies = cookies
end

Class Method Details

.new_or_nil_if_invalid(cookies) ⇒ Object



14
15
16
17
# File 'lib/devise_facebook_open_graph/facebook/session.rb', line 14

def self.new_or_nil_if_invalid(cookies)
  session = new(cookies)
  return session if session.valid?
end

Instance Method Details

Returns facebook’s cookie content



29
30
31
# File 'lib/devise_facebook_open_graph/facebook/session.rb', line 29

def cookie_content
  @cookie_content ||= parse_cookie
end

#graphObject

Gives access to query as user with an oauth access token fetched from the cookie content



36
37
38
# File 'lib/devise_facebook_open_graph/facebook/session.rb', line 36

def graph
  Koala::Facebook::GraphAPI.new(access_token)
end

#valid?Boolean

Is this a valid session? True if we were able to parse facebook’s cookie content

Returns:

  • (Boolean)


53
54
55
# File 'lib/devise_facebook_open_graph/facebook/session.rb', line 53

def valid?
  !!cookie_content
end