Class: Brewser::MashSchedule

Inherits:
Model
  • Object
show all
Defined in:
lib/brewser/model/mash_schedule.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



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/brewser/model/mash_schedule.rb', line 12

def self.json_create(o)
  return nil if o.blank?
  a = self.new
  a.name = o['name']
  a.description = o['description']
  a.grain_temp = o['grain_temperature'].u unless o['grain_temperature'].blank?
  a.sparge_temp = o['sparge_temperature'].u unless o['sparge_temperature'].blank?
  o['mash_steps'].each do |step|
    a.mash_steps.push step
  end unless o['mash_steps'].nil?

  return a
end

Instance Method Details

#as_json(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/brewser/model/mash_schedule.rb', line 26

def as_json(options={})
  {
    JSON.create_id => "Brewser::MashSchedule",
      'name' => name, 'description' => description, 
      'grain_temperature' => grain_temp.to_s, 'sparge_temperature' => sparge_temp.to_s,
      'mash_steps' => mash_steps.to_a
  }
end