Skip to content

Instantly share code, notes, and snippets.

@luxerama
Created November 29, 2013 12:10

Revisions

  1. luxerama created this gist Nov 29, 2013.
    8 changes: 8 additions & 0 deletions auth.rb
    Original 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
    6 changes: 6 additions & 0 deletions profile.rb
    Original 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
    11 changes: 11 additions & 0 deletions token.rb
    Original 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