Sha256: d4ba08b0d2239274ad1d427d08fff0c28e166317276db7bcef9e48ea46f47ec9
Contents?: true
Size: 681 Bytes
Versions: 2
Compression:
Stored size: 681 Bytes
Contents
# frozen_string_literal: true module Nuva class Repository attr_reader :data def initialize(data) @data = index_array_by_id(data) end def find(id) @data[id] end def all @data.values end def by_ids(ids) ids.map { |x| find x }.compact end # def by_ids(ids) # @data.select { |k, _v| ids.include?(k) }.values # end private def index_array_by_id(array) array.each_with_object({}) { |item, acc| acc[item.id] = item } end end end require_relative 'repositories/disease_repository' require_relative 'repositories/vaccine_repository' require_relative 'repositories/valence_repository'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nuva-0.1.8 | lib/nuva/repository.rb |
nuva-0.1.7 | lib/nuva/repository.rb |