Class: Chef::ChefFS::DataHandler::OrganizationDataHandler

Inherits:
DataHandlerBase
  • Object
show all
Defined in:
lib/chef/chef_fs/data_handler/organization_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(organization, entry) ⇒ Object



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

def normalize(organization, entry)
  normalize_hash(organization, {
    "name" => entry.org,
    "full_name" => entry.org,
    "org_type" => "Business",
    "clientname" => "#{entry.org}-validator",
    "billing_plan" => "platform-free",
  })
end

#preserve_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/chef/chef_fs/data_handler/organization_data_handler.rb', line 17

def preserve_key?(key)
  key == "name"
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



27
28
29
30
31
# File 'lib/chef/chef_fs/data_handler/organization_data_handler.rb', line 27

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