Class: AccessTokenWrapper::FromRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/access_token_wrapper/from_record.rb

Constant Summary

Constants inherited from Base

Base::EXPIRY_GRACE_SEC

Instance Attribute Summary collapse

Attributes inherited from Base

#raw_token

Instance Method Summary collapse

Methods inherited from Base

#config

Constructor Details

#initialize(client:, record:, &callback) ⇒ AccessTokenWrapper::FromRecord

This is the core functionality

Examples:

AccessTokenWrapper::FromRecord.new(client: client, record: user) do |new_token, exception|
  update_user_from_access_token(new_token)
end

Parameters:

  • client (<OAuth2::Client>)

    An instance of an OAuth2::Client object

  • record (<Object>)

    An AR-like object that responds to ‘access_token`, `refresh_token`, `expires_at`, `with_lock` and `reload`.

  • callback (&block)

    A callback that gets called when a token is refreshed, the callback is provided ‘new_token` and optional `exception` parameters



23
24
25
26
27
# File 'lib/access_token_wrapper/from_record.rb', line 23

def initialize(client:, record:, &callback)
  @oauth_client = client
  @record       = record
  super(build_token, &callback)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AccessTokenWrapper::Base

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



5
6
7
# File 'lib/access_token_wrapper/from_record.rb', line 5

def record
  @record
end