Class: OpsWorks::Layer
Instance Attribute Summary collapse
-
#custom_recipes ⇒ Object
Returns the value of attribute custom_recipes.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#shortname ⇒ Object
Returns the value of attribute shortname.
Attributes inherited from Resource
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Resource
Constructor Details
This class inherits a constructor from OpsWorks::Resource
Instance Attribute Details
#custom_recipes ⇒ Object
Returns the value of attribute custom_recipes.
3 4 5 |
# File 'lib/opsworks/layer.rb', line 3 def custom_recipes @custom_recipes end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/opsworks/layer.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/opsworks/layer.rb', line 3 def name @name end |
#shortname ⇒ Object
Returns the value of attribute shortname.
3 4 5 |
# File 'lib/opsworks/layer.rb', line 3 def shortname @shortname end |
Class Method Details
.from_collection_response(client, response) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/opsworks/layer.rb', line 5 def self.from_collection_response(client, response) response.data[:layers].map do |layer| hash = layer.to_h # Make custom_recipes accessible by string or symbol custom_recipes = Thor::CoreExt::HashWithIndifferentAccess.new( hash[:custom_recipes] ) new( client, id: hash[:layer_id], name: hash[:name], shortname: hash[:shortname], custom_recipes: custom_recipes ) end end |
Instance Method Details
#add_custom_recipe(event, recipe) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/opsworks/layer.rb', line 22 def add_custom_recipe(event, recipe) return if custom_recipes[event].include?(recipe) custom_recipes[event] ||= [] custom_recipes[event].push recipe client.update_layer( layer_id: id, custom_recipes: custom_recipes ) end |
#remove_custom_recipe(event, recipe) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/opsworks/layer.rb', line 33 def remove_custom_recipe(event, recipe) return unless custom_recipes[event].include?(recipe) custom_recipes[event].delete recipe client.update_layer( layer_id: id, custom_recipes: custom_recipes ) end |