Class: Nuva::Queries::ValencesByVaccine
- Inherits:
-
Object
- Object
- Nuva::Queries::ValencesByVaccine
- Defined in:
- lib/nuva/queries.rb
Instance Method Summary collapse
- #call(vaccine) ⇒ Object
-
#initialize(repositories) ⇒ ValencesByVaccine
constructor
A new instance of ValencesByVaccine.
Constructor Details
#initialize(repositories) ⇒ ValencesByVaccine
Returns a new instance of ValencesByVaccine.
8 9 10 11 12 13 14 15 16 |
# File 'lib/nuva/queries.rb', line 8 def initialize(repositories) hash = Hash.new { |h, k| h[k] = [] } @valences_by_vaccine_id = repositories[:valences].all.reduce(hash) do |acc, valence| valence.vaccine_ids.each do |vaccine_id| acc[vaccine_id] << valence end acc end end |
Instance Method Details
#call(vaccine) ⇒ Object
18 19 20 |
# File 'lib/nuva/queries.rb', line 18 def call(vaccine) @valences_by_vaccine_id[vaccine.id] end |