lib/cfer/core/resource.rb in cfer-0.5.0.pre.rc4 vs lib/cfer/core/resource.rb in cfer-0.5.0
- old
+ new
@@ -20,10 +20,11 @@
# @param k [String] The name of the tag to set
# @param v [String] The value for this tag
# @param options [Hash] An arbitrary set of additional properties to be added to this tag, for example `PropagateOnLaunch` on `AWS::AutoScaling::AutoScalingGroup`
def tag(k, v, **options)
self[:Properties][:Tags] ||= []
+ self[:Properties][:Tags].delete_if { |kv| kv["Key"] == k }
self[:Properties][:Tags].unshift({"Key" => k, "Value" => v}.merge(options))
end
# Directly sets raw properties in the underlying CloudFormation structure.
# @param keyvals [Hash] The properties to set on this object.
@@ -51,17 +52,17 @@
resource_class(type).class_eval(&block)
end
# Registers a hook that will be run before properties are set on a resource
# @param type [String] The type of resource, for example `AWS::EC2::Instance`
- def before(type, &block)
- resource_class(type).pre_hooks << block
+ def before(type, options = {}, &block)
+ resource_class(type).pre_hooks << options.merge(block: block)
end
# Registers a hook that will be run after properties have been set on a resource
# @param type [String] The type of resource, for example `AWS::EC2::Instance`
- def after(type, &block)
- resource_class(type).post_hooks << block
+ def after(type, options = {}, &block)
+ resource_class(type).post_hooks << options.merge(block: block)
end
end
end
end