Module: Jsonable::ClassMethods

Defined in:
lib/jsonable.rb

Instance Method Summary collapse

Instance Method Details

#from_json(json_string) ⇒ Object



23
24
25
# File 'lib/jsonable.rb', line 23

def from_json(json_string)
  return JSON.parse(json_string)
end

#json_create(object) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/jsonable.rb', line 12

def json_create(object)
  obj = new
  object.each do |key, value|
    next if key == 'json_class'
    #puts "setting #{key}: #{value}"
    obj.instance_variable_set key, value
    #puts "x = #{obj.x}"
  end
  obj
end