Sha256: 92abc97538d8cc0d9212c4b39c32f3c5070ef5eabb1b322172f95c299a46c8b2
Contents?: true
Size: 1.19 KB
Versions: 6
Compression:
Stored size: 1.19 KB
Contents
require 'opsworks/resource' require 'thor' module OpsWorks class Layer < Resource attr_accessor :id, :name, :shortname, :custom_recipes # rubocop:disable MethodLength def self.from_collection_response(response) response.data[:layers].map do |hash| # Make custom_recipes accessible by string or symbol custom_recipes = Thor::CoreExt::HashWithIndifferentAccess.new( hash[:custom_recipes] ) new( id: hash[:layer_id], name: hash[:name], shortname: hash[:shortname], custom_recipes: custom_recipes ) end end # rubocop:enable MethodLength def add_custom_recipe(event, recipe) return if custom_recipes[event].include?(recipe) custom_recipes[event] ||= [] custom_recipes[event].push recipe self.class.client.update_layer( layer_id: id, custom_recipes: custom_recipes ) end def remove_custom_recipe(event, recipe) return unless custom_recipes[event].include?(recipe) custom_recipes[event].delete recipe self.class.client.update_layer( layer_id: id, custom_recipes: custom_recipes ) end end end
Version data entries
6 entries across 6 versions & 1 rubygems