class Jets::Stack
def build?
def build? empty = template == {"Parameters"=>{"IamRole"=>{"Type"=>"String"}, "S3Bucket"=>{"Type"=>"String"}}} !empty end
def eager_load_shared_resources!
Eager loading the app/shared resources to ensure shared resources have been registered.
def eager_load_shared_resources! Dir.glob("#{Jets.root}/app/shared/**").each do |path| next if path.include?("app/shared/functions") Jets::Autoloaders.main.preload(path) end end
def functions
def functions stack = new # All the & because resources might be nil templates = stack.resources&.map(&:template)&.select do |t| attributes = t.values.first attributes['Type'] == 'AWS::Lambda::Function' end templates ||= [] templates.map { |t| Function.new(t) } end
def inherited(base)
def inherited(base) super self.subclasses << base if base.name end
def looker
def looker Jets::Stack::Output::Lookup.new(self) end
def lookup(logical_id)
def lookup(logical_id) looker.output(logical_id) end
def new_class(class_name, &block)
def new_class(class_name, &block) # https://stackoverflow.com/questions/4113479/dynamic-class-definition-with-a-class-name # Defining the constant this way gets around: SyntaxError: dynamic constant assignment error klass = Class.new(Jets::Stack) # First klass is an anonymous class. IE: class.name is nil klass = Object.const_set(class_name, klass) # now klass is a named class Jets::Stack.subclasses << klass # mimic inherited hook because # Must run class_eval after adding to subclasses in order for the resource declarations in the # so that the resources get registered to the right subclass. klass.class_eval(&block) klass # return klass end
def output_keys
def output_keys outputs = new.outputs || [] outputs.map(&:template).map {|o| o.keys.first} end
def subclasses
def subclasses @subclasses ||= [] end
def template
def template # Pretty funny looking, creating an instance of stack to be passed to the Builder. # Another way of looking at it: # # stack = new # MyStack.new # builder = Jets::Stack::Builder.new(stack) # builder = Jets::Stack::Builder.new(new) builder.template end