Class: CommandTower::Secrets::Cleanse

Inherits:
Object
  • Object
show all
Includes:
CommandTower::ServiceLogging
Defined in:
app/services/command_tower/secrets/cleanse.rb

Overview

Drops every outstanding secret a user holds for one reason.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommandTower::ServiceLogging

included

Constructor Details

#initialize(user:, reason:) ⇒ Cleanse

Returns a new instance of Cleanse.



12
13
14
15
# File 'app/services/command_tower/secrets/cleanse.rb', line 12

def initialize(user:, reason:)
  @user = user
  @reason = reason
end

Class Method Details

.call(user:, reason:) ⇒ Object



8
9
10
# File 'app/services/command_tower/secrets/cleanse.rb', line 8

def self.call(user:, reason:)
  new(user:, reason:).call
end

Instance Method Details

#callObject



17
18
19
20
21
22
# File 'app/services/command_tower/secrets/cleanse.rb', line 17

def call
  count = UserSecret.where(user:, reason:).delete_all
  log_info("Cleansed #{count} #{reason} secret(s) from the store for user [#{user.id}]")

  count
end