Class: Account::Service::Confirmation

Inherits:
Object
  • Object
show all
Defined in:
app/models/aikotoba/account/service/confirmation.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account:) ⇒ Confirmation

Returns a new instance of Confirmation.



13
14
15
# File 'app/models/aikotoba/account/service/confirmation.rb', line 13

def initialize(account:)
  @account = 
end

Class Method Details

.confirm!(account:) ⇒ Object



9
10
11
# File 'app/models/aikotoba/account/service/confirmation.rb', line 9

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

.create_token!(account:, notify: false) ⇒ Object



5
6
7
# File 'app/models/aikotoba/account/service/confirmation.rb', line 5

def self.create_token!(account:, notify: false)
  new(account: ).create_token!(notify: notify)
end

Instance Method Details

#confirm!Object



24
25
26
27
28
29
# File 'app/models/aikotoba/account/service/confirmation.rb', line 24

def confirm!
  ActiveRecord::Base.transaction do
    @account.confirm!
    @account.confirmation_token&.destroy!
  end
end

#create_token!(notify:) ⇒ Object



17
18
19
20
21
22
# File 'app/models/aikotoba/account/service/confirmation.rb', line 17

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