Class: AuctionFunCore::Operations::AuctionContext::PreAuction::AuctionStartReminderOperation

Inherits:
Base
  • Object
show all
Defined in:
lib/auction_fun_core/operations/auction_context/pre_auction/auction_start_reminder_operation.rb

Overview

Operation class for sending a reminder email to a participant about the start of an auction.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(attributes) {|Dry::Matcher::Evaluator| ... } ⇒ Dry::Matcher::Evaluator

Executes the auction start reminder operation with the provided attributes.

Parameters:

  • attributes (Hash)

    The attributes for the auction start reminder operation.

Yields:

  • (Dry::Matcher::Evaluator)

    The block to handle the result of the operation.

Returns:

  • (Dry::Matcher::Evaluator)

    The result of the operation.



22
23
24
25
26
27
28
# File 'lib/auction_fun_core/operations/auction_context/pre_auction/auction_start_reminder_operation.rb', line 22

def self.call(attributes, &block)
  operation = new.call(attributes)

  return operation unless block

  Dry::Matcher::ResultMatcher.call(operation, &block)
end

Instance Method Details

#call(attributes) ⇒ Dry::Monads::Result

Executes the auction start reminder operation.

Parameters:

  • attributes (Hash)

    The attributes for the auction start reminder operation.

Returns:

  • (Dry::Monads::Result)

    The result of the operation.



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/auction_fun_core/operations/auction_context/pre_auction/auction_start_reminder_operation.rb', line 36

def call(attributes)
  auction = yield validate_contract(attributes)
  participant_ids = yield collect_current_auction_participants(auction.id)

  bid_repository.transaction do |_t|
    participant_ids.each do |participant_id|
      yield send_auction_start_reminder_mailer_job(auction.id, participant_id)
    end
  end

  Success([auction, participant_ids])
end