Class: AccountComponent::Commands::Deposit
- Inherits:
-
Object
- Object
- AccountComponent::Commands::Deposit
- Includes:
- Command
- Defined in:
- lib/account_component/commands/deposit.rb
Class Method Summary collapse
- .call(account_id:, amount:, deposit_id: nil, previous_message: nil) ⇒ Object
- .configure(receiver, attr_name: nil) ⇒ Object
Instance Method Summary collapse
Methods included from Command
Class Method Details
.call(account_id:, amount:, deposit_id: nil, previous_message: nil) ⇒ Object
12 13 14 15 16 |
# File 'lib/account_component/commands/deposit.rb', line 12 def self.call(account_id:, amount:, deposit_id: nil, previous_message: nil) deposit_id ||= Identifier::UUID::Random.get instance = self.build instance.(deposit_id: deposit_id, account_id: account_id, amount: amount, previous_message: ) end |
.configure(receiver, attr_name: nil) ⇒ Object
6 7 8 9 10 |
# File 'lib/account_component/commands/deposit.rb', line 6 def self.configure(receiver, attr_name: nil) attr_name ||= :deposit instance = build receiver.public_send("#{attr_name}=", instance) end |
Instance Method Details
#call(deposit_id:, account_id:, amount:, previous_message: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/account_component/commands/deposit.rb', line 18 def call(deposit_id:, account_id:, amount:, previous_message: nil) deposit = self.class.(Messages::Commands::Deposit, ) deposit.deposit_id = deposit_id deposit.account_id = account_id deposit.amount = amount deposit.time = clock.iso8601 stream_name = command_stream_name(account_id) write.(deposit, stream_name) deposit end |