Class: Ridley::EnvironmentObject

Inherits:
ChefObject show all
Defined in:
lib/ridley/chef_objects/environment_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 an environment level default attribute given the dotted path representation of the Chef attribute and value

Examples:

setting and saving an environment level default attribute


obj = environment.find("production")
obj.set_default_attribute("my_app.billing.enabled", false)
obj.save

Parameters:

  • key (String)
  • value (Object)

Returns:

  • (Hashie::Mash)


35
36
37
38
# File 'lib/ridley/chef_objects/environment_object.rb', line 35

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 an environment level override attribute given the dotted path representation of the Chef attribute and value

Examples:

setting and saving an environment level override attribute


obj = environment.find("production")
obj.set_override_attribute("my_app.billing.enabled", false)
obj.save

Parameters:

  • key (String)
  • value (Object)

Returns:

  • (Hashie::Mash)


53
54
55
56
# File 'lib/ridley/chef_objects/environment_object.rb', line 53

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

#unset_default_attribute(key) ⇒ Hashie::Mash Also known as: delete_default_attribute

Removes a environment default attribute given its dotted path representation. Returns the default attributes of the environment.

Parameters:

  • key (String)

    the dotted path to an attribute

Returns:

  • (Hashie::Mash)


65
66
67
# File 'lib/ridley/chef_objects/environment_object.rb', line 65

def unset_default_attribute(key)
  unset_attribute(key, :default)
end

#unset_override_attribute(key) ⇒ Hashie::Mash Also known as: delete_override_attribute

Removes a environment override attribute given its dotted path representation. Returns the override attributes of the environment.

Parameters:

  • key (String)

    the dotted path to an attribute

Returns:

  • (Hashie::Mash)


77
78
79
# File 'lib/ridley/chef_objects/environment_object.rb', line 77

def unset_override_attribute(key)
  unset_attribute(key, :override)
end