lib/cfer/core/resource.rb in cfer-0.6.2 vs lib/cfer/core/resource.rb in cfer-0.7.0

- old
+ new

@@ -1,9 +1,24 @@ module Cfer::Core class Resource < Cfer::BlockHash include Cfer::Core::Hooks + class Handle + attr_reader :name + def initialize(name) + @name = name.to_s + end + + def ref + Functions::Fn::ref(name) + end + + def method_missing(method) + Functions::Fn::get_att(name, method.to_s.camelize) + end + end + @@types = {} attr_reader :stack def initialize(name, type, stack, **options, &block) @@ -12,9 +27,13 @@ self[:Type] = type self.merge!(options) self[:Properties] = HashWithIndifferentAccess.new build_from_block(&block) + end + + def handle + @handle ||= Handle.new(@name) end # Sets a tag on this resource. The resource must support the CloudFormation `Tags` property. # @param k [String] The name of the tag to set # @param v [String] The value for this tag