Class: HolisticAuth::OrmHandlers::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/holistic_auth/orm_handlers/active_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info, provider_name) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



9
10
11
12
# File 'lib/holistic_auth/orm_handlers/active_record.rb', line 9

def initialize(info, provider_name)
  @info = info
  @provider_name = provider_name
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



7
8
9
# File 'lib/holistic_auth/orm_handlers/active_record.rb', line 7

def 
  @account
end

#infoObject (readonly)

Returns the value of attribute info.



7
8
9
# File 'lib/holistic_auth/orm_handlers/active_record.rb', line 7

def info
  @info
end

#provider_nameObject (readonly)

Returns the value of attribute provider_name.



7
8
9
# File 'lib/holistic_auth/orm_handlers/active_record.rb', line 7

def provider_name
  @provider_name
end

Instance Method Details

#discover_account!Object



18
19
20
# File 'lib/holistic_auth/orm_handlers/active_record.rb', line 18

def discover_account!
  @account.present? ? @account : (@account = )
end

#discover_user!Object



14
15
16
# File 'lib/holistic_auth/orm_handlers/active_record.rb', line 14

def discover_user!
  discover_account!.user
end

#store_provider_credentials!(access_token) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/holistic_auth/orm_handlers/active_record.rb', line 22

def store_provider_credentials!(access_token)
  raise 'Account not discovered yet!' unless @account.present?

  @account.replace_credential!(
    access_token: access_token.token,
    refresh_token: access_token.refresh_token,
    expires_at: (Time.now.utc + access_token.expires_in),
    expires: access_token.expires_in.present? ? true : false,
  )
end