Module: SimpleRecord::Json::ClassMethods

Defined in:
lib/simple_record/json.rb

Instance Method Summary collapse

Instance Method Details

#from_json(json_string) ⇒ Object



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

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

#json_create(object) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/simple_record/json.rb', line 10

def json_create(object)
    obj = new
    for key, value in object
        next if key == 'json_class'
        if key == 'id'
            obj.id = value
            next
        end
        obj.set key, value
    end
    obj
end