Class: Nuva::Queries::DiseasesByValence

Inherits:
Object
  • Object
show all
Defined in:
lib/nuva/queries.rb

Instance Method Summary collapse

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