Class: AppleData::LockdownData
Overview
Schema file for the ‘lockdownd.yaml` file
Instance Method Summary
collapse
Methods inherited from DataFile
#auto_sort?, #collection, from_path, #load_file, #save, #save!, #sort!
Constructor Details
Returns a new instance of LockdownData.
7
8
9
10
11
12
|
# File 'lib/apple_data/lockdown.rb', line 7
def initialize
super('lockdownd.yaml')
@data ||= {}
@data['clients'] ||= []
@data['domains'] ||= []
end
|
Instance Method Details
#data ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/apple_data/lockdown.rb', line 38
def data
@data['clients'].sort!
@data['domains'].each do |domain|
domain['properties'].sort!
end
@data['domains'].sort_by! { |d| d['name'] }
@data
end
|
#ensure_client(client) ⇒ Object
14
15
16
|
# File 'lib/apple_data/lockdown.rb', line 14
def ensure_client(client)
@data['clients'] << client unless @data['clients'].include? client
end
|
#ensure_domain_has_property(domain, property, _type = nil) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/apple_data/lockdown.rb', line 18
def ensure_domain_has_property(domain, property, _type = nil)
domain_instance = get_domain domain
return unless property
domain_instance['properties'] << property unless domain_instance['properties'].include? property
end
|
#get_domain(domain) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/apple_data/lockdown.rb', line 26
def get_domain(domain)
result = @data['domains'].find { |d| d['name'] == domain }
unless result
result = {}
result['name'] = domain
@data['domains'] << result
end
result['description'] ||= nil
result['properties'] ||= []
result
end
|