Class: LockdownData

Inherits:
DataFile
  • Object
show all
Defined in:
lib/apple_data/lockdown.rb

Overview

Schema file for the ‘lockdownd.yaml` file

Instance Method Summary collapse

Constructor Details

#initializeLockdownData

Returns a new instance of LockdownData.



5
6
7
8
9
10
# File 'lib/apple_data/lockdown.rb', line 5

def initialize
  super 'lockdownd.yaml'
  @data ||= {}
  @data['clients'] ||= []
  @data['domains'] ||= []
end

Instance Method Details

#dataObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/apple_data/lockdown.rb', line 36

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



12
13
14
# File 'lib/apple_data/lockdown.rb', line 12

def ensure_client(client)
  @data['clients'] << client unless @data['clients'].include? client
end

#ensure_domain_has_property(domain, property, _type = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/apple_data/lockdown.rb', line 16

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



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/apple_data/lockdown.rb', line 24

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