Class: Chef::ChefFS::DataHandler::RoleDataHandler

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

Instance Method Summary collapse

Methods inherited from DataHandlerBase

#chef_object, #default, #from_ruby, #minimize, #normalize_for_post, #normalize_for_put, #normalize_hash, #normalize_run_list, #remove_file_extension, #to_ruby_keys, #verify_integrity

Instance Method Details

#chef_classObject



30
31
32
# File 'lib/chef/chef_fs/data_handler/role_data_handler.rb', line 30

def chef_class
  Chef::Role
end

#normalize(role, entry) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chef/chef_fs/data_handler/role_data_handler.rb', line 8

def normalize(role, entry)
  result = normalize_hash(role, {
    "name" => remove_file_extension(entry.name),
    "description" => "",
    "json_class" => "Chef::Role",
    "chef_type" => "role",
    "default_attributes" => {},
    "override_attributes" => {},
    "run_list" => [],
    "env_run_lists" => {},
  })
  result["run_list"] = normalize_run_list(result["run_list"])
  result["env_run_lists"].each_pair do |env, run_list|
    result["env_run_lists"][env] = normalize_run_list(run_list)
  end
  result
end

#preserve_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/chef/chef_fs/data_handler/role_data_handler.rb', line 26

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

#to_ruby(object) ⇒ Object



34
35
36
# File 'lib/chef/chef_fs/data_handler/role_data_handler.rb', line 34

def to_ruby(object)
  to_ruby_keys(object, %w{name description default_attributes override_attributes run_list env_run_lists})
end