Class: Okei::FindUnit

Inherits:
Hexx::UseCase
  • Object
show all
Includes:
Wisper::Publisher
Defined in:
app/use_cases/okei/find_unit.rb

Overview

Finds an unit by name:

use_case = GetUnit.new name: "1000 человеко-часов"
use_case.run
# => #<Okei::Unit @code: "ТЫС ЧЕЛ-ЧАС" ...>

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`



29
30
31
32
33
# File 'app/use_cases/okei/find_unit.rb', line 29

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