Class: Nuva::Queries::ValencesByDiseaseQuery
- Defined in:
- lib/nuva/queries.rb
Instance Method Summary collapse
- #call(disease) ⇒ Object
-
#initialize(repositories) ⇒ ValencesByDiseaseQuery
constructor
A new instance of ValencesByDiseaseQuery.
Methods inherited from Query
Constructor Details
#initialize(repositories) ⇒ ValencesByDiseaseQuery
Returns a new instance of ValencesByDiseaseQuery.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/nuva/queries.rb', line 73 def initialize(repositories) hash = Hash.new { |h, k| h[k] = [] } @valences_by_disease_id = repositories[:valences] .all .reduce(hash) do |acc, valence| valence.disease_ids.each do |disease_id| acc[disease_id] << valence end acc end end |
Instance Method Details
#call(disease) ⇒ Object
86 87 88 |
# File 'lib/nuva/queries.rb', line 86 def call(disease) @valences_by_disease_id[disease.id] end |