Class: Chef::ChefFS::DataHandler::PolicyGroupDataHandler

Inherits:
DataHandlerBase show all
Defined in:
lib/chef/chef_fs/data_handler/policy_group_data_handler.rb

Instance Method Summary collapse

Methods inherited from DataHandlerBase

#chef_class, #chef_object, #default, #from_ruby, #minimize, #normalize_for_post, #normalize_for_put, #normalize_hash, #normalize_run_list, #preserve_key?, #remove_file_extension, #to_ruby, #to_ruby_keys

Instance Method Details

#normalize(policy_group, entry) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/chef/chef_fs/data_handler/policy_group_data_handler.rb', line 8

def normalize(policy_group, entry)
  defaults = {
    "name" => remove_dot_json(entry.name),
    "policies" => {},
  }
  result = normalize_hash(policy_group, defaults)
  result.delete("uri") # not useful data
  result
end

#verify_integrity(object_data, entry) {|s| ... } ⇒ Object

Verify that the JSON hash for this type has a key that matches its name.

Parameters:

Yields:

  • (s)

    callback to handle errors

Yield Parameters:

  • error (s<string>)

    message



24
25
26
27
28
# File 'lib/chef/chef_fs/data_handler/policy_group_data_handler.rb', line 24

def verify_integrity(object_data, entry)
  if object_data["policies"].empty?
    yield("Policy group #{object_data["name"]} does not have any policies in it.")
  end
end