Class: Chef::ChefFS::DataHandler::GroupDataHandler

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

Instance Method Summary collapse

Methods inherited from DataHandlerBase

#chef_object, #default, #from_ruby, #minimize, #normalize_hash, #normalize_run_list, #remove_file_extension, #to_ruby, #to_ruby_keys, #verify_integrity

Instance Method Details

#chef_classObject


47
48
49
# File 'lib/chef/chef_fs/data_handler/group_data_handler.rb', line 47

def chef_class
  Chef::ApiClient
end

#normalize(group, 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/group_data_handler.rb', line 8

def normalize(group, entry)
  defaults = {
    "name" => remove_dot_json(entry.name),
    "groupname" => remove_dot_json(entry.name),
    "users" => [],
    "clients" => [],
    "groups" => [],
  }
  if entry.org
    defaults["orgname"] = entry.org
  end
  result = normalize_hash(group, defaults)
  if result["actors"] && result["actors"].sort.uniq == (result["users"] + result["clients"]).sort.uniq
    result.delete("actors")
  end
  result
end

#normalize_for_post(group, entry) ⇒ Object


39
40
41
# File 'lib/chef/chef_fs/data_handler/group_data_handler.rb', line 39

def normalize_for_post(group, entry)
  normalize_for_put(group, entry)
end

#normalize_for_put(group, entry) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/chef/chef_fs/data_handler/group_data_handler.rb', line 26

def normalize_for_put(group, entry)
  result = super(group, entry)
  result["actors"] = {
    "users" => result["users"],
    "clients" => result["clients"],
    "groups" => result["groups"],
  }
  result.delete("users")
  result.delete("clients")
  result.delete("groups")
  result
end

#preserve_key?(key) ⇒ Boolean


43
44
45
# File 'lib/chef/chef_fs/data_handler/group_data_handler.rb', line 43

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