Class: OauthService

Inherits:
Object
  • Object
show all
Defined in:
app/services/oauth_service.rb

Overview

Handles OAuth connection and user management.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth, user_id = nil) ⇒ OauthService

This method initializes oauth object

Parameters:

  • auth (Hash)

    of user details

  • user_id (Integer) (defaults to: nil)

    of verifying user.

[View source]

10
11
12
13
# File 'app/services/oauth_service.rb', line 10

def initialize(auth, user_id = nil)
  @auth = auth
  @user_id = user_id
end

Instance Attribute Details

#authHash

stores information retrieved after oauth call

Returns:

  • (Hash)

    the current value of auth


5
6
7
# File 'app/services/oauth_service.rb', line 5

def auth
  @auth
end

#user_idInteger

stores user id of verifying user

Returns:

  • (Integer)

    the current value of user_id


5
6
7
# File 'app/services/oauth_service.rb', line 5

def user_id
  @user_id
end

Instance Method Details

#connect_userMethod

This method allows for connection and login with same service.

Returns:

  • (Method)

    existing_user (to allow for connecting various accounts)

  • (Method)

    new_user (to allow for login)

[View source]

19
20
21
# File 'app/services/oauth_service.rb', line 19

def connect_user
  @user_id.present? ? existing_user : new_user
end