Class: Nuva::Queries::ValencesByDisease

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

Instance Method Summary collapse

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