Class: Convection::Model::Template::ResourceProperty

Inherits:
Object
  • Object
show all
Includes:
DSL::Helpers
Defined in:
lib/convection/model/template/resource_property.rb,
lib/convection/model/template/resource_property/aws_ec2_mount_point.rb,
lib/convection/model/template/resource_property/aws_lambda_vpc_config.rb,
lib/convection/model/template/resource_property/aws_cloudfront_origin.rb,
lib/convection/model/template/resource_property/aws_cloudfront_logging.rb,
lib/convection/model/template/resource_property/aws_events_rule_target.rb,
lib/convection/model/template/resource_property/aws_cloudfront_s3origin.rb,
lib/convection/model/template/resource_property/aws_lambda_function_code.rb,
lib/convection/model/template/resource_property/aws_s3_cors_configuration.rb,
lib/convection/model/template/resource_property/aws_ec2_network_interface.rb,
lib/convection/model/template/resource_property/aws_cloudfront_customorigin.rb,
lib/convection/model/template/resource_property/aws_cloudfront_restrictions.rb,
lib/convection/model/template/resource_property/aws_ec2_block_device_mapping.rb,
lib/convection/model/template/resource_property/aws_cloudfront_cachebehavior.rb,
lib/convection/model/template/resource_property/aws_cloudfront_georestriction.rb,
lib/convection/model/template/resource_property/aws_cloudfront_forwardedvalues.rb,
lib/convection/model/template/resource_property/aws_s3_cors_configuration_rule.rb,
lib/convection/model/template/resource_property/aws_ec2_block_store_block_device.rb,
lib/convection/model/template/resource_property/aws_cloudfront_viewercertificate.rb,
lib/convection/model/template/resource_property/aws_cloudfront_distribution_config.rb,
lib/convection/model/template/resource_property/aws_cloudfront_customerrorresponse.rb,
lib/convection/model/template/resource_property/aws_cloudfront_defaultcachebehavior.rb

Overview

Base class for Resource Property Types

Defined Under Namespace

Classes: CloudFrontCacheBehavior, CloudFrontCustomErrorResponse, CloudFrontCustomOrigin, CloudFrontDefaultCacheBehavior, CloudFrontDistributionConfig, CloudFrontForwardedValues, CloudFrontGeoRestriction, CloudFrontLogging, CloudFrontOrigin, CloudFrontRestrictions, CloudFrontS3Origin, CloudFrontViewerCertificate, EC2BlockDeviceMapping, EC2BlockStoreBlockDevice, EC2MountPoint, EC2NetworkInterface, EventsRuleTarget, LambdaFunctionCode, LambdaVpcConfig, S3CorsConfiguration, S3CorsConfigurationRule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL::Helpers

#camel_case, included, method_name, #screaming_snake_case, #snake_case

Methods included from DSL::IntrinsicFunctions

#base64, #find_in_map, #fn_and, #fn_equals, #fn_if, #fn_not, #fn_or, #fn_ref, #get_att, #get_azs, #join, #select

Constructor Details

#initialize(parent) ⇒ ResourceProperty

Returns a new instance of ResourceProperty



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/convection/model/template/resource_property.rb', line 31

def initialize(parent)
  @template = parent.template
  @exist = false

  ## Instantiate properties
  @properties = Model::Collection.new
  resource = self
  resource.class.properties.each do |_, property|
    @properties[property.property_name] = property.instance(resource)
  end
end

Instance Attribute Details

#existObject (readonly) Also known as: exist?

Returns the value of attribute exist



28
29
30
# File 'lib/convection/model/template/resource_property.rb', line 28

def exist
  @exist
end

#propertiesObject (readonly)

Returns the value of attribute properties



27
28
29
# File 'lib/convection/model/template/resource_property.rb', line 27

def properties
  @properties
end

#templateObject (readonly)

Resource Property Instance Methods



26
27
28
# File 'lib/convection/model/template/resource_property.rb', line 26

def template
  @template
end

Class Method Details

.attach_method(name, &block) ⇒ Object



16
17
18
# File 'lib/convection/model/template/resource_property.rb', line 16

def attach_method(name, &block)
  define_method(name, &block)
end

.propertiesObject



7
8
9
# File 'lib/convection/model/template/resource_property.rb', line 7

def properties
  @properties ||= {}
end

.property(accesor, property_name, options = {}) ⇒ Object



11
12
13
14
# File 'lib/convection/model/template/resource_property.rb', line 11

def property(accesor, property_name, options = {})
  properties[accesor] = Resource::Property.create(accesor, property_name, options)
  properties[accesor].attach(self)
end

Instance Method Details

#property(key, *value) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/convection/model/template/resource_property.rb', line 43

def property(key, *value)
  return properties[key].value if value.empty?

  ## Define a property instance on the fly
  properties[key] = ScalarPropertyInstance.new(self) unless properties.include?(key)
  properties[key].set(*value)
end

#renderObject



51
52
53
# File 'lib/convection/model/template/resource_property.rb', line 51

def render
  properties.map(true, &:render)
end