lib/project/PackingPeanut.rb in PackingPeanut-0.0.2 vs lib/project/PackingPeanut.rb in PackingPeanut-0.0.3

- old
+ new

@@ -1,18 +1,5 @@ - -# Potential fixes for type specifics -# Super fix #1 -> Serialize it: http://stackoverflow.com/questions/7057845/save-arraylist-to-sharedpreferences -# ObjectSerializer: https://github.com/apache/pig/blob/89c2e8e76c68d0d0abe6a36b4e08ddc56979796f/src/org/apache/pig/impl/util/ObjectSerializer.java -# https://pig.apache.org/releases.html -# Super fix #2 -> Store depending on the class and retrieve with either -# A: Failover defaults calling methods -# B: Grab ALL data, and use that hash -# Super fix #3 -> Serialize with JSON -# new Gson().toJson(obj) -# And for deserialization, - - module App module Persistence MODE_PRIVATE = 0 MODE_WORLD_READABLE = 1 @@ -43,10 +30,11 @@ editor.commit end def [](key) json_string = get_value(key) + return json_string if json_string == "" deserialize(key, json_string) end def serialize(key, value) json = JSONObject.new @@ -58,10 +46,10 @@ json.get(key) end def get_value key settings = get_settings - value = settings.getString(key,nil) + settings.getString(key,nil) end def storage_file=(value) @persistence_storage_file = value end