Class: Nuva::ValenceRepository

Inherits:
Repository show all
Defined in:
lib/nuva/repositories/valence_repository.rb

Instance Attribute Summary

Attributes inherited from Repository

#data

Instance Method Summary collapse

Methods inherited from Repository

#all, #by_ids, #find

Constructor Details

#initialize(data) ⇒ ValenceRepository

Returns a new instance of ValenceRepository.



5
6
7
8
9
10
11
12
13
# File 'lib/nuva/repositories/valence_repository.rb', line 5

def initialize(data)
  super data
  @ancestor_ids_by_id = {}
  @data.each_value do |valence|
    # Build hash of ancestor IDs for valence
    @ancestor_ids_by_id[valence.id] = lookup_ancestors(valence).uniq
  end
  @ancestor_ids_by_id.freeze
end

Instance Method Details

#get_ancestor_ids(valence_id) ⇒ Object



15
16
17
# File 'lib/nuva/repositories/valence_repository.rb', line 15

def get_ancestor_ids(valence_id)
  @ancestor_ids_by_id[valence_id]
end