Class: Procore::Auth::Stores::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/procore/auth/stores/active_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object:) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



7
8
9
# File 'lib/procore/auth/stores/active_record.rb', line 7

def initialize(object:)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



5
6
7
# File 'lib/procore/auth/stores/active_record.rb', line 5

def object
  @object
end

Instance Method Details

#deleteObject



27
28
29
30
31
32
33
# File 'lib/procore/auth/stores/active_record.rb', line 27

def delete
  object.update(
    access_token: nil,
    expires_at: nil,
    refresh_token: nil,
  )
end

#fetchObject



19
20
21
22
23
24
25
# File 'lib/procore/auth/stores/active_record.rb', line 19

def fetch
  Procore::Auth::Token.new(
    access_token: object.access_token,
    refresh_token: object.refresh_token,
    expires_at: object.expires_at,
  )
end

#save(token) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/procore/auth/stores/active_record.rb', line 11

def save(token)
  object.update(
    access_token: token.access_token,
    refresh_token: token.refresh_token,
    expires_at: token.expires_at,
  )
end

#to_sObject



35
36
37
# File 'lib/procore/auth/stores/active_record.rb', line 35

def to_s
  "Active Record, Object: #{object.class} #{object.id}"
end