Class: Nuva::Queries::VaccinesByValenceQuery
- Defined in:
- lib/nuva/queries.rb
Instance Method Summary collapse
- #call(valence) ⇒ Object
-
#initialize(repositories) ⇒ VaccinesByValenceQuery
constructor
A new instance of VaccinesByValenceQuery.
Methods inherited from Query
Constructor Details
#initialize(repositories) ⇒ VaccinesByValenceQuery
Returns a new instance of VaccinesByValenceQuery.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nuva/queries.rb', line 33 def initialize(repositories) hash = Hash.new { |h, k| h[k] = [] } @vaccines_by_valence_id = repositories[:vaccines] .all .reduce(hash) do |acc, vaccine| vaccine.valence_ids.each do |valence_id| acc[valence_id] << vaccine end acc end end |
Instance Method Details
#call(valence) ⇒ Object
46 47 48 |
# File 'lib/nuva/queries.rb', line 46 def call(valence) @vaccines_by_valence_id[valence.id] end |