Class: Ridley::RoleObject

Inherits:
ChefObject show all
Defined in:
lib/ridley/chef_objects/role_object.rb

Instance Method Summary collapse

Methods inherited from ChefObject

#<=>, #==, chef_id, #chef_id, chef_json_class, chef_type, #eql?, #hash, #initialize, #inspect, #reload, #save, set_chef_id, set_chef_json_class, set_chef_type, #update

Constructor Details

This class inherits a constructor from Ridley::ChefObject

Instance Method Details

#set_default_attribute(key, value) ⇒ Hashie::Mash

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:

  • (Hashie::Mash)


56
57
58
59
# File 'lib/ridley/chef_objects/role_object.rb', line 56

def set_default_attribute(key, value)
  attr_hash = Hashie::Mash.from_dotted_path(key, value)
  self.default_attributes = self.default_attributes.deep_merge(attr_hash)
end

#set_override_attribute(key, value) ⇒ Hashie::Mash

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:

  • (Hashie::Mash)


38
39
40
41
# File 'lib/ridley/chef_objects/role_object.rb', line 38

def set_override_attribute(key, value)
  attr_hash = Hashie::Mash.from_dotted_path(key, value)
  self.override_attributes = self.override_attributes.deep_merge(attr_hash)
end