Class: Amazon::Util::UserDataStore
- Inherits:
-
Object
- Object
- Amazon::Util::UserDataStore
- Defined in:
- lib/amazon/util/user_data_store.rb
Overview
The UserDataStore is a platform-independent class intended to store application configuration information in a human-readable per-user location.
Instance Method Summary collapse
- #clear(namespace, property = nil) ⇒ Object
- #get(namespace, property) ⇒ Object
-
#initialize(app_name) ⇒ UserDataStore
constructor
A new instance of UserDataStore.
- #save ⇒ Object
- #set(namespace, property, value) ⇒ Object
Constructor Details
#initialize(app_name) ⇒ UserDataStore
Returns a new instance of UserDataStore.
12 13 14 15 16 17 18 |
# File 'lib/amazon/util/user_data_store.rb', line 12 def initialize(app_name) @app = sanitizeKey(app_name) @base = findBaseStore(@app) @dirty = [] @data = Hash.new {|h,a| h[a] = {} } loadConfig end |
Instance Method Details
#clear(namespace, property = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/amazon/util/user_data_store.rb', line 31 def clear(namespace,property = nil) ns = sanitizeKey(namespace) @dirty << ns unless @dirty.member? ns if property.nil? @data[ns] = {} else @data[ns].delete_if {|k,v| k == property } end end |
#get(namespace, property) ⇒ Object
20 21 22 23 |
# File 'lib/amazon/util/user_data_store.rb', line 20 def get(namespace,property) ns = sanitizeKey(namespace) @data[ns][property] end |
#save ⇒ Object
41 42 43 44 45 |
# File 'lib/amazon/util/user_data_store.rb', line 41 def save @dirty.delete_if do |name| saveNamespace( name ) end end |
#set(namespace, property, value) ⇒ Object
25 26 27 28 29 |
# File 'lib/amazon/util/user_data_store.rb', line 25 def set(namespace,property,value) ns = sanitizeKey(namespace) @dirty << ns unless @dirty.member? ns @data[ns][property] = value end |