Class: FluShot::Prescription

Inherits:
Object
  • Object
show all
Defined in:
lib/flu_shot/prescription.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Prescription

Returns a new instance of Prescription.



7
8
9
10
# File 'lib/flu_shot/prescription.rb', line 7

def initialize(name)
  @name = name
  self.class.prescriptions.add(@name, [])
end

Class Method Details

.for(name) ⇒ Object



18
19
20
# File 'lib/flu_shot/prescription.rb', line 18

def self.for(name)
  prescriptions.get(name)
end

.spec(name, &block) ⇒ Object



3
4
5
# File 'lib/flu_shot/prescription.rb', line 3

def self.spec(name, &block)
  block.call(self.new(name)) if block_given?
end

Instance Method Details

#add(vaccine, params = {}) ⇒ Object



12
13
14
15
16
# File 'lib/flu_shot/prescription.rb', line 12

def add(vaccine, params = {})
  current = self.class.prescriptions.get(@name)
  current << { vaccine: vaccine, params: params }
  self.class.prescriptions.add(@name, current)
end