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.
Instance Method Summary collapse
-
#initialize(domain) ⇒ Store
constructor
A new instance of Store.
- #plist ⇒ Object
- #plist_path ⇒ Object
- #set(key, value) ⇒ Object
- #to_binary ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(domain) ⇒ Store
8 9 10 |
# File 'lib/mac_app_sync/defaults/store.rb', line 8 def initialize(domain) @domain = domain 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 |
Instance Method Details
#plist ⇒ Object
20 21 22 |
# File 'lib/mac_app_sync/defaults/store.rb', line 20 def plist @plist ||= CFPropertyList::List.new(file: plist_path) end |
#plist_path ⇒ Object
33 34 35 |
# File 'lib/mac_app_sync/defaults/store.rb', line 33 def plist_path @plist_path ||= prefs_file_path || container_file_path end |
#set(key, value) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/mac_app_sync/defaults/store.rb', line 24 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
16 17 18 |
# File 'lib/mac_app_sync/defaults/store.rb', line 16 def to_binary plist.to_str(CFPropertyList::List::FORMAT_XML) end |
#values ⇒ Object
12 13 14 |
# File 'lib/mac_app_sync/defaults/store.rb', line 12 def values PlistConverter.to_ruby(plist.value) end |