Class: Chef::ChefFS::DataHandler::ContainerDataHandler

Inherits:
DataHandlerBase show all
Defined in:
lib/chef/chef_fs/data_handler/container_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, #remove_file_extension, #to_ruby, #to_ruby_keys

Instance Method Details

#normalize(container, entry) ⇒ Object



7
8
9
10
11
12
# File 'lib/chef/chef_fs/data_handler/container_data_handler.rb', line 7

def normalize(container, entry)
  normalize_hash(container, {
    "containername" => remove_dot_json(entry.name),
    "containerpath" => remove_dot_json(entry.name),
  })
end

#preserve_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/chef/chef_fs/data_handler/container_data_handler.rb', line 14

def preserve_key?(key)
  key == "containername"
end

#verify_integrity(object, 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
29
# File 'lib/chef/chef_fs/data_handler/container_data_handler.rb', line 24

def verify_integrity(object, entry)
  base_name = remove_dot_json(entry.name)
  if object["containername"] != base_name
    yield("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object["containername"]}')")
  end
end