Class: PersonalAccessTokens::LastUsedService

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

Instance Method Summary collapse

Constructor Details

#initialize(personal_access_token) ⇒ LastUsedService

Returns a new instance of LastUsedService.



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

def initialize(personal_access_token)
  @personal_access_token = personal_access_token
end

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
# File 'app/services/personal_access_tokens/last_used_service.rb', line 9

def execute
  # Needed to avoid calling service on Oauth tokens
  return unless @personal_access_token.has_attribute?(:last_used_at)

  # We _only_ want to update last_used_at and not also updated_at (which
  # would be updated when using #touch).
  @personal_access_token.update_column(:last_used_at, Time.zone.now) if update?
end