Created
November 29, 2013 12:10
Revisions
-
luxerama created this gist
Nov 29, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ class Auth attr_accessible :token def authorised? token = self.token if token.valid? token =|| token.refresh token ? true : false end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ class Profile def self.fetch raise UnauthoriseError, 'Un-Authorised attempt to fetch profile' unless Auth.authorised? # continue fetching profile end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ class Token attr_accessible :token, :expires_in, :refresh_token def valid? # return false if expired, true otherwise end def refresh_token # refresh token and expiry end end