Class: Ridley::RoleResource

Inherits:
Resource show all
Defined in:
lib/ridley/resources/role_resource.rb

Overview

Author:

Instance Method Summary collapse

Methods inherited from Resource

#<=>, #==, all, #chef_id, chef_id, chef_json_class, chef_type, create, delete, delete_all, #eql?, find, find!, #hash, #initialize, #reload, resource_path, #save, set_chef_id, set_chef_json_class, set_chef_type, set_resource_path, #to_s, update, #update

Constructor Details

This class inherits a constructor from Ridley::Resource

Instance Method Details

#set_default_attribute(key, value) ⇒ HashWithIndifferentAccess

Set a role level default attribute given the dotted path representation of the Chef attribute and value

Examples:

setting and saving a node level default attribute


obj = node.role("why_god_why")
obj.set_default_attribute("my_app.billing.enabled", false)
obj.save

Parameters:

  • key (String)
  • value (Object)

Returns:

  • (HashWithIndifferentAccess)

58
59
60
61
# File 'lib/ridley/resources/role_resource.rb', line 58

def set_default_attribute(key, value)
  attr_hash = HashWithIndifferentAccess.from_dotted_path(key, value)
  self.default_attributes = self.default_attributes.deep_merge(attr_hash)
end

#set_override_attribute(key, value) ⇒ HashWithIndifferentAccess

Set a role level override attribute given the dotted path representation of the Chef attribute and value

Examples:

setting and saving a node level override attribute


obj = node.role("why_god_why")
obj.set_override_attribute("my_app.billing.enabled", false)
obj.save

Parameters:

  • key (String)
  • value (Object)

Returns:

  • (HashWithIndifferentAccess)

40
41
42
43
# File 'lib/ridley/resources/role_resource.rb', line 40

def set_override_attribute(key, value)
  attr_hash = HashWithIndifferentAccess.from_dotted_path(key, value)
  self.override_attributes = self.override_attributes.deep_merge(attr_hash)
end