Class: Ridley::Environment

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

Overview

Author:

Class Method Summary collapse

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

Class Method Details

.delete_all(connection) ⇒ Array<Ridley::Environment>

Delete all of the environments on the remote connection. The ‘_default’ environment will never be deleted.

Parameters:

Returns:



13
14
15
16
# File 'lib/ridley/resources/environment.rb', line 13

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

Instance Method Details

#cookbook_versions=(hash) ⇒ Object



42
43
44
# File 'lib/ridley/resources/environment.rb', line 42

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

#default_attributes=(hash) ⇒ Object

Parameters:

  • hash (Hash)


33
34
35
# File 'lib/ridley/resources/environment.rb', line 33

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

#override_attributes=(hash) ⇒ Object

Parameters:

  • hash (Hash)


38
39
40
# File 'lib/ridley/resources/environment.rb', line 38

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

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


59
60
61
62
# File 'lib/ridley/resources/environment.rb', line 59

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)


77
78
79
80
# File 'lib/ridley/resources/environment.rb', line 77

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