Class: Nuva::Queries::AllCodeByNomenclature
- Inherits:
-
Object
- Object
- Nuva::Queries::AllCodeByNomenclature
- Defined in:
- lib/nuva/queries.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(repositories) ⇒ AllCodeByNomenclature
constructor
A new instance of AllCodeByNomenclature.
Constructor Details
#initialize(repositories) ⇒ AllCodeByNomenclature
Returns a new instance of AllCodeByNomenclature.
201 202 203 |
# File 'lib/nuva/queries.rb', line 201 def initialize(repositories) @vaccines = repositories.vaccines end |
Instance Method Details
#call ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/nuva/queries.rb', line 205 def call @vaccines .all .flat_map(&:codes) .reduce(Hash.new { |hash, key| hash[key] = [] }) { |hash, code| hash[code.nomenclature] << code.value hash } .map { |key, value| [key, value.uniq] } .to_h end |