Class: Okei::GetUnit

Inherits:
Hexx::UseCase
  • Object
show all
Defined in:
app/use_cases/okei/get_unit.rb

Overview

Finds an unit by uuid:

use_case = GetUnit.new uuid: "581dfac6-5b58-4227-a242-503f5f8a275d"
use_case.run
# => #<Okei::Unit @uuid: "581dfac6-5b58-4227-a242-503f5f8a275d" ...>

Any other parameters are ignored.

Allows subscription before running:

use_case.subscribe logger
use_case.subscribe controller
use_case.run

Instance Method Summary collapse

Instance Method Details

#run!Object

Runs the method:

  • оn success publishes ‘found(unit)` and returns an `unit`

  • on error raises ‘Hexx::NotFoundError` with `self`



28
29
30
31
32
# File 'app/use_cases/okei/get_unit.rb', line 28

def run!
  unit_found?
  publish :found, unit
  unit
end