Class: HolisticAuth::OrmHandlers::ActiveRecord
- Inherits:
-
Object
- Object
- HolisticAuth::OrmHandlers::ActiveRecord
- Defined in:
- lib/holistic_auth/orm_handlers/active_record.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#provider_name ⇒ Object
readonly
Returns the value of attribute provider_name.
Instance Method Summary collapse
- #discover_account! ⇒ Object
- #discover_user! ⇒ Object
-
#initialize(info, provider_name) ⇒ ActiveRecord
constructor
A new instance of ActiveRecord.
- #store_provider_credentials!(access_token) ⇒ Object
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
#account ⇒ Object (readonly)
Returns the value of attribute account.
7 8 9 |
# File 'lib/holistic_auth/orm_handlers/active_record.rb', line 7 def account @account end |
#info ⇒ Object (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_name ⇒ Object (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 = find_or_create_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 |