Module: Doodle::JSON::ClassMethods

Defined in:
lib/doodle/json.rb

Instance Method Summary collapse

Instance Method Details

#from_json(src) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/doodle/json.rb', line 23

def from_json(src)
  v = ::JSON::parse(src)
  if v.kind_of?(Hash)
    new(v)
  else
    v
  end
end

#json_create(o) ⇒ Object



18
19
20
21
22
# File 'lib/doodle/json.rb', line 18

def json_create(o)
  #pp [:json_create, o]
  const = Doodle::Utils.const_resolve(o['json_class'])
  const.new(o['data'])
end