Class: Brewser::MashStep

Inherits:
Model
  • Object
show all
Defined in:
lib/brewser/model/mash_steps.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#as_beerxml, #as_brewson, auto_migrate_down!, auto_migrate_up!, auto_upgrade!, default_repository_name

Class Method Details

.json_create(o) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/brewser/model/mash_steps.rb', line 24

def self.json_create(o)
  return nil if o.blank?
  a = self.new
  a.name = o['name']
  a.index = o['index']
  a.description = o['description']
  a.type = o['type']
  a.purpose = o['purpose']
  a.step_volume = o['step_volume'].u unless o['step_volume'].blank?
  a.ramp_time = o['ramp_time'].u unless o['ramp_time'].blank?
  a.water_to_grain_ratio = o['water_to_grain_ratio']
  a.infusion_volume = o['infusion_volume'].u unless o['infusion_volume'].blank?
  a.infusion_temperature = o['infusion_temperature'].u unless o['infusion_temperature'].blank?
  a.rest_temperature = o['rest_temperature'].u unless o['rest_temperature'].blank?
  a.rest_time = o['rest_time'].u unless o['rest_time'].blank?

  return a
end

Instance Method Details

#as_json(options = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/brewser/model/mash_steps.rb', line 43

def as_json(options={})
  {
    JSON.create_id => "Brewser::MashStep",
    'name' => name, 'index' => index, 'description' => description, 
    'type' => type, 'purpose' => purpose,
    'step_volume' => step_volume.to_s, 'ramp_time' => ramp_time.to_s,
    'infusion_volume' => infusion_volume.to_s, 'infusion_temperature' => infusion_temperature.to_s,
    'rest_temperature' => rest_temperature.to_s, 'rest_time' => rest_time.to_s,
    'water_to_grain_ratio' => water_to_grain_ratio 
  }
end