Class: Ridley::EnvironmentResource

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

Overview

Author:

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#<=>, #==, all, #chef_id, chef_id, chef_json_class, chef_type, create, delete, #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

Class Method Details

.delete_all(client) ⇒ Array<Ridley::EnvironmentResource>

Delete all of the environments on the client. The '_default' environment will never be deleted.

Parameters:

Returns:


11
12
13
14
# File 'lib/ridley/resources/environment_resource.rb', line 11

def delete_all(client)
  envs = all(client).reject { |env| env.name.to_s == '_default' }
  envs.collect { |obj| delete(client, obj) }
end

Instance Method Details

#set_default_attribute(key, value) ⇒ HashWithIndifferentAccess

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_defualt_attribute("my_app.billing.enabled", false)
obj.save

Parameters:

  • key (String)
  • value (Object)

Returns:

  • (HashWithIndifferentAccess)

50
51
52
53
# File 'lib/ridley/resources/environment_resource.rb', line 50

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 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:

  • (HashWithIndifferentAccess)

68
69
70
71
# File 'lib/ridley/resources/environment_resource.rb', line 68

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