Class: Nuva::Queries::ValencesByDisease
- Inherits:
-
Object
- Object
- Nuva::Queries::ValencesByDisease
- Defined in:
- lib/nuva/queries.rb
Instance Method Summary collapse
- #call(disease) ⇒ Object
-
#initialize(repositories) ⇒ ValencesByDisease
constructor
A new instance of ValencesByDisease.
Constructor Details
#initialize(repositories) ⇒ ValencesByDisease
Returns a new instance of ValencesByDisease.
58 59 60 61 62 63 64 65 66 |
# File 'lib/nuva/queries.rb', line 58 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
68 69 70 |
# File 'lib/nuva/queries.rb', line 68 def call(disease) @valences_by_disease_id[disease.id] end |