Class: MacAppSync::Defaults::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/mac_app_sync/defaults/store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#domainObject (readonly)

Returns the value of attribute domain.



6
7
8
# File 'lib/mac_app_sync/defaults/store.rb', line 6

def domain
  @domain
end

#plistObject (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_pathObject



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_binaryObject



17
18
19
# File 'lib/mac_app_sync/defaults/store.rb', line 17

def to_binary
  plist.to_str(CFPropertyList::List::FORMAT_XML)
end

#valuesObject



13
14
15
# File 'lib/mac_app_sync/defaults/store.rb', line 13

def values
  PlistConverter.to_ruby(plist.value)
end