Module: Yapper::Settings
Constant Summary collapse
- PREFIX =
'yapper-'
Instance Method Summary collapse
Instance Method Details
#delete(key) ⇒ Object
24 25 26 27 |
# File 'lib/yapper/settings.rb', line 24 def delete(key) storage.removeObjectForKey(storage_key(key)) storage.synchronize end |
#get(key) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/yapper/settings.rb', line 9 def get(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 |
#purge ⇒ Object
29 30 31 32 |
# File 'lib/yapper/settings.rb', line 29 def purge storage.dictionaryRepresentation.keys.each { |key| self.delete(key.gsub(/^#{PREFIX}/,'')) if key =~ /^#{PREFIX}/ } storage.synchronize end |
#set(key, value) ⇒ Object
19 20 21 22 |
# File 'lib/yapper/settings.rb', line 19 def set(key, value) storage.setObject(value, forKey: storage_key(key)) storage.synchronize end |