Class: MacAppSync::Defaults::Store
- Inherits:
-
Object
- Object
- MacAppSync::Defaults::Store
- Defined in:
- lib/mac_app_sync/defaults/store.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#plist ⇒ Object
readonly
Returns the value of attribute plist.
Instance Method Summary collapse
-
#initialize(domain) ⇒ Store
constructor
A new instance of Store.
- #plist_path ⇒ Object
- #set(key, value) ⇒ Object
- #to_binary ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(domain) ⇒ Store
Returns a new instance of Store.
8 9 10 11 |
# File 'lib/mac_app_sync/defaults/store.rb', line 8 def initialize(domain) @domain = domain @plist = load_plist end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
6 7 8 |
# File 'lib/mac_app_sync/defaults/store.rb', line 6 def domain @domain end |
#plist ⇒ Object (readonly)
Returns the value of attribute plist.
6 7 8 |
# File 'lib/mac_app_sync/defaults/store.rb', line 6 def plist @plist end |
Instance Method Details
#plist_path ⇒ Object
30 31 32 |
# File 'lib/mac_app_sync/defaults/store.rb', line 30 def plist_path @plist_path ||= prefs_file_path || container_file_path end |
#set(key, value) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/mac_app_sync/defaults/store.rb', line 21 def set(key, value) new_value = PlistConverter.to_plist(value) current_value = plist.value.value[key] if Comparator.different?(current_value, new_value) plist.value.value[key] = new_value end end |
#to_binary ⇒ Object
17 18 19 |
# File 'lib/mac_app_sync/defaults/store.rb', line 17 def to_binary plist.to_str(CFPropertyList::List::FORMAT_XML) end |
#values ⇒ Object
13 14 15 |
# File 'lib/mac_app_sync/defaults/store.rb', line 13 def values PlistConverter.to_ruby(plist.value) end |