Class: Formulary::QHPDrugRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/formulary/qhp_drug_repo.rb

Overview

Simple in-memory storage for instances of QHPDrug

Class Method Summary collapse

Class Method Details

.allObject



22
23
24
# File 'lib/formulary/qhp_drug_repo.rb', line 22

def self.all
  repo
end

.drugs_for_plan(plan) ⇒ Object



18
19
20
# File 'lib/formulary/qhp_drug_repo.rb', line 18

def self.drugs_for_plan(plan)
  repo.select { |drug| drug.in_plan? plan.id }
end

.import(raw_qhp_drugs) ⇒ Object



12
13
14
15
16
# File 'lib/formulary/qhp_drug_repo.rb', line 12

def self.import(raw_qhp_drugs)
  raw_qhp_drugs.each do |raw_drug|
    repo << QHPDrug.new(raw_drug)
  end
end

.repoObject



8
9
10
# File 'lib/formulary/qhp_drug_repo.rb', line 8

def self.repo
  @repo ||= reset!
end

.reset!Object



26
27
28
# File 'lib/formulary/qhp_drug_repo.rb', line 26

def self.reset!
  @repo = []
end