motion/core/persistence.rb in bubble-wrap-1.1.2 vs motion/core/persistence.rb in bubble-wrap-1.1.3
- old
+ new
@@ -11,10 +11,16 @@
storage.setObject(value, forKey: storage_key(key))
storage.synchronize
end
def [](key)
- storage.objectForKey storage_key(key)
+ value = storage.objectForKey storage_key(key)
+
+ # RubyMotion currently has a bug where the strings returned from
+ # standardUserDefaults are missing some methods (e.g. to_data).
+ # And because the returned object is slightly different than a normal
+ # String, we can't just use `value.is_a?(String)`
+ value.class.to_s == 'String' ? value.dup : value
end
def merge(values)
values.each do |key, value|
storage.setObject(value, forKey: storage_key(key))