Sha256: 53fa4ef7b926aa54081d138d8af058e9f346b973546c6b86f9b0ccc634965cf1

Contents?: true

Size: 672 Bytes

Versions: 1

Compression:

Stored size: 672 Bytes

Contents

# frozen_string_literal: true

module Aikotoba
  class Account::Service::Registration
    def self.call!(account:)
      new.call!(account: account)
    end

    def initialize
      @account_class = Account
      @confirm_service = Account::Service::Confirmation
      @confirmable = @account_class.confirmable?
    end

    def call!(account:)
      ActiveRecord::Base.transaction do
        account.save!
        send_confirmation_token!(account) if @confirmable
      end
    end

    private

    concerning :Confirmable do
      def send_confirmation_token!(account)
        @confirm_service.create_token!(account: account, notify: true)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aikotoba-0.1.0 app/models/aikotoba/account/service/registration.rb