Class: Nuva::Queries::AllCodeByNomenclatureQuery
- Defined in:
- lib/nuva/queries.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(repositories) ⇒ AllCodeByNomenclatureQuery
constructor
A new instance of AllCodeByNomenclatureQuery.
Methods inherited from Query
Constructor Details
#initialize(repositories) ⇒ AllCodeByNomenclatureQuery
Returns a new instance of AllCodeByNomenclatureQuery.
217 218 219 |
# File 'lib/nuva/queries.rb', line 217 def initialize(repositories) @vaccines = repositories.vaccines end |
Instance Method Details
#call ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/nuva/queries.rb', line 221 def call @vaccines .all .flat_map(&:codes) .reduce(Hash.new { |hash, key| hash[key] = [] }) do |hash, code| hash[code.nomenclature] << code.value hash end .map { |key, value| [key, value.uniq] } .to_h end |