Class: Nuva::Queries::DiseasesByValence
- Inherits:
-
Object
- Object
- Nuva::Queries::DiseasesByValence
- Defined in:
- lib/nuva/queries.rb
Instance Method Summary collapse
- #call(valence) ⇒ Object
-
#initialize(repositories) ⇒ DiseasesByValence
constructor
A new instance of DiseasesByValence.
Constructor Details
#initialize(repositories) ⇒ DiseasesByValence
Returns a new instance of DiseasesByValence.
92 93 94 95 96 97 98 99 100 |
# File 'lib/nuva/queries.rb', line 92 def initialize(repositories) hash = Hash.new { |h, k| h[k] = [] } @diseases_by_valence_id = repositories[:diseases].all.reduce(hash) do |acc, disease| disease.valence_ids.each do |valence_id| acc[valence_id] << disease end acc end end |
Instance Method Details
#call(valence) ⇒ Object
102 103 104 |
# File 'lib/nuva/queries.rb', line 102 def call(valence) @diseases_by_valence_id[valence.id] end |