Sha256: 2f457e3ebed1305c2431cd7f63c4dded96f5f73734c2facbc55036d1fa2a5a3e

Contents?: true

Size: 694 Bytes

Versions: 2

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

module Aikotoba
  class Account::Service::Confirmation
    def self.create_token!(account:, notify: false)
      new(account: account).create_token!(notify: notify)
    end

    def self.confirm!(account:)
      new(account: account).confirm!
    end

    def initialize(account:)
      @account = account
    end

    def create_token!(notify:)
      ActiveRecord::Base.transaction do
        @account.build_confirmation_token.save!
        @account.confirmation_token.notify if notify
      end
    end

    def confirm!
      ActiveRecord::Base.transaction do
        @account.confirm!
        @account.confirmation_token&.destroy!
      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/confirmation.rb
aikotoba-0.1.0 app/models/aikotoba/account/service/confirmation.rb