Class: Ridley::Role

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/ridley/resources/role.rb

Instance Method Summary collapse

Methods included from Resource

#<=>, #==, #attribute, #attribute=, #attribute?, #attributes, #attributes=, #chef_id, #eql?, #from_hash, #from_json, #hash, #initialize, #reload, #save, #to_hash, #to_json, #to_s

Instance Method Details

#default_attributes=(hash) ⇒ Object

Parameters:

  • hash (Hash)


21
22
23
# File 'lib/ridley/resources/role.rb', line 21

def default_attributes=(hash)
  super(HashWithIndifferentAccess.new(hash))
end

#override_attributes=(hash) ⇒ Object

Parameters:

  • hash (Hash)


26
27
28
# File 'lib/ridley/resources/role.rb', line 26

def override_attributes=(hash)
  super(HashWithIndifferentAccess.new(hash))
end

#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)


61
62
63
64
# File 'lib/ridley/resources/role.rb', line 61

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)


43
44
45
46
# File 'lib/ridley/resources/role.rb', line 43

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