Class: AppleData::Lockdown
- Inherits:
-
DataFile
- Object
- DataFile
- AppleData::Lockdown
- Defined in:
- lib/apple_data/lockdown.rb
Overview
Schema file for the lockdownd.yaml file
Instance Method Summary collapse
- #data ⇒ Object
- #ensure_client(client) ⇒ Object
- #ensure_domain_has_property(domain, property, _type = nil) ⇒ Object
- #get_domain(domain) ⇒ Object
-
#initialize ⇒ Lockdown
constructor
A new instance of Lockdown.
Constructor Details
#initialize ⇒ Lockdown
Returns a new instance of Lockdown.
7 8 9 10 11 12 13 |
# File 'lib/apple_data/lockdown.rb', line 7 def initialize super('lockdownd.yaml') @data ||= {} # : 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
15 16 17 |
# File 'lib/apple_data/lockdown.rb', line 15 def ensure_client(client) @data['clients'] << client unless @data['clients'].include? client end |
#ensure_domain_has_property(domain, property, _type = nil) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/apple_data/lockdown.rb', line 30 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
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/apple_data/lockdown.rb', line 19 def get_domain(domain) result = @data['domains'].find { |d| d['name'] == domain } unless result result = { 'name' => domain } # : domain @data['domains'] << result end result['description'] ||= nil result['properties'] ||= [] result end |