class Skywriter::ResourceProperty
Attributes
options[R]
Public Class Methods
new(options = {})
click to toggle source
@param [Hash] options Options hash. Valid values depend on the implementing class - see the AWS documentation
at http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-product-property-reference.html for details
# File lib/skywriter/resource_property.rb, line 13 def initialize(options = {}) @options = options.freeze end
property(name)
click to toggle source
Declare a ResourceProperty
property
@param name [Symbol] The property name as it exists in the AWS documentation
# File lib/skywriter/resource_property.rb, line 6 def self.property(name) property_definitions << PropertyDefinition.new(name) end
Private Class Methods
property_definitions()
click to toggle source
# File lib/skywriter/resource_property.rb, line 33 def self.property_definitions @property_definitions ||= [] end
Public Instance Methods
as_json(*)
click to toggle source
Returns a JSON-able hash representing the Resource
@return [Hash] A JSON-able hash
# File lib/skywriter/resource_property.rb, line 21 def as_json(*) @as_json ||= property_definitions.each_with_object({}) do |property_definition, hash| if (value = property_value(property_definition)) hash[property_definition.name] = value.as_json end end end
Private Instance Methods
property_definitions()
click to toggle source
# File lib/skywriter/resource_property.rb, line 44 def property_definitions self.class.property_definitions end
property_value(property_definition)
click to toggle source
# File lib/skywriter/resource_property.rb, line 37 def property_value(property_definition) options[property_definition.key.to_sym] || options[property_definition.key.to_s] || options[property_definition.name.to_sym] || options[property_definition.name.to_s] end