Class: Brewser::Additive

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



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

def self.json_create(o)
  a = self.new
  a.name = o['name']
  a.description = o['description']
  a.type = o['type']
  a.added_when = o['added_when']
  a.time = o['time'].u unless o['time'].blank?
  a.amount = o['amount'].u unless o['amount'].blank?
  a.use_for = o['use_for']

  return a
end

Instance Method Details

#as_json(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/brewser/model/additive.rb', line 27

def as_json(options={})
  {
    JSON.create_id => "Brewser::Additive",
    'name' => name, 
    'description' => description, 
    'type' => type, 
    'added_when' => added_when, 
    'time' => time.to_s, 'amount' => amount.to_s, 
    'use_for' => use_for
  }
end