Sha256: 9dd28df5f3a9802683a0bdba38ebe38821cdc3f2df6d46477bf3776b18ed64a6

Contents?: true

Size: 1.35 KB

Versions: 217

Compression:

Stored size: 1.35 KB

Contents

# Class that include Definition should implement:
#
#   template - method should use @definition to build a CloudFormation template section
#
class Jets::Stack
  module Definition
    extend ActiveSupport::Concern

    # Example of usage that leads here:
    #
    #   Parameter.new(self, *definition).register
    #
    # Which  is defined in parameter/dsl.rb
    #
    # Example subclass: ExampleStack < Jets::Stack
    def initialize(subclass, *definition)
      @subclass = subclass.to_s # important to use to_s, dont want the object as keys in @definitions
      @definition = definition.flatten
    end

    def register
      self.class.register(@subclass, *@definition)
    end

    def camelize(attributes)
      Jets::Camelizer.transform(attributes)
    end

    class_methods do
      def register(subclass, *definition)
        @definitions ||= {}
        @definitions[subclass.to_s] ||= []
        # Create instance of the CloudFormation section class and register it.  Examples:
        #   Stack::Parameter.new(definition)
        #   Stack::Resource.new(definition)
        #   Stack::Output.new(definition)
        @definitions[subclass.to_s] << new(subclass, definition)
      end

      def definitions(subclass)
        @definitions ||= {}
        @definitions[subclass.to_s]
      end

      def all_definitions
        @definitions
      end
    end
  end
end

Version data entries

217 entries across 217 versions & 4 rubygems

Version Path
jets-4.0.12 lib/jets/stack/definition.rb
jets-4.0.11 lib/jets/stack/definition.rb
jets-4.0.10 lib/jets/stack/definition.rb
jets-4.0.9 lib/jets/stack/definition.rb
jets-4.0.8 lib/jets/stack/definition.rb
jets-4.0.7 lib/jets/stack/definition.rb
jets-4.0.6 lib/jets/stack/definition.rb
jets-4.0.5 lib/jets/stack/definition.rb
jets-4.0.4 lib/jets/stack/definition.rb
jets-4.0.3 lib/jets/stack/definition.rb
jets-4.0.2 lib/jets/stack/definition.rb
jets-4.0.1 lib/jets/stack/definition.rb
jets-4.0.0 lib/jets/stack/definition.rb
jets-3.2.2 lib/jets/stack/definition.rb
jets-3.2.1 lib/jets/stack/definition.rb
jets.benforeva-3.0.17.pre.mount.pre.fix lib/jets/stack/definition.rb
jets-3.2.0 lib/jets/stack/definition.rb
jets-3.1.5 lib/jets/stack/definition.rb
jets-3.1.4 lib/jets/stack/definition.rb
jets-3.1.3 lib/jets/stack/definition.rb