Sha256: e3046e64bd713956c633d1c3b59d6d236334c00e2422482ddba747b3fd044f59
Contents?: true
Size: 938 Bytes
Versions: 2
Compression:
Stored size: 938 Bytes
Contents
# frozen_string_literal: true module Aikotoba class Account::Service::Lock def self.lock!(account:, notify: false) new(account: account).lock!(notify: notify) end def self.unlock!(account:) new(account: account).unlock! end def self.create_unlock_token!(account:, notify: false) new(account: account).create_unlock_token!(notify: notify) end def initialize(account:) @account = account end def lock!(notify:) ActiveRecord::Base.transaction do @account.lock! create_unlock_token!(notify: notify) end end def unlock! ActiveRecord::Base.transaction do @account.unlock! @account.unlock_token&.destroy! end end def create_unlock_token!(notify:) ActiveRecord::Base.transaction do @account.build_unlock_token.save! @account.unlock_token.notify if notify end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aikotoba-0.1.1 | app/models/aikotoba/account/service/lock.rb |
aikotoba-0.1.0 | app/models/aikotoba/account/service/lock.rb |