Class: EnviaYa::Rates::Application::Commands::CreateRateCommand
- Inherits:
-
Object
- Object
- EnviaYa::Rates::Application::Commands::CreateRateCommand
- Defined in:
- lib/modules/rates/application/commands/create_rate_command.rb
Instance Method Summary collapse
- #execute(create_rate_dto) ⇒ Object
-
#initialize(repository:) ⇒ CreateRateCommand
constructor
A new instance of CreateRateCommand.
Constructor Details
#initialize(repository:) ⇒ CreateRateCommand
Returns a new instance of CreateRateCommand.
9 10 11 12 13 |
# File 'lib/modules/rates/application/commands/create_rate_command.rb', line 9 def initialize(repository:) raise TypeError, "repository expected CreateRateRepository but got: #{repository.class}" unless repository.is_a?(::EnviaYa::Rates::Domain::Repositories::RatesRepository) @repository = repository end |
Instance Method Details
#execute(create_rate_dto) ⇒ Object
15 16 17 18 19 |
# File 'lib/modules/rates/application/commands/create_rate_command.rb', line 15 def execute(create_rate_dto) raise TypeError, "expected CreateRateDto but got: #{create_rate_dto.class}" unless create_rate_dto.is_a?(::EnviaYa::Rates::Domain::Dtos::CreateRateDto) @repository.create(create_rate_dto) end |