Class: Jets::Cfn::Resource::Associated

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/jets/cfn/resource/associated.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*definition) ⇒ Associated

Returns a new instance of Associated.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jets/cfn/resource/associated.rb', line 9

def initialize(*definition)
  @definition = definition.flatten
  # Some associated resources require multiple resources for a single Lambda function. For
  # example `sqs_event` can create a `SQS::Queue` and `Lambda::EventSourceMapping`.  We set
  # a `multiple` flag so `add_logical_id_counter` can use it to avoid adding counter ids to
  # these type of resources. The `multiple` flag allows us to handle both:
  #
  #   1. Associated resources that contain multiple resources for a single Lambda function
  #   2. A single Lambda function with multiple events.  In this case, a counter is added
  #
  # Setting `multiple` to true means the counter id will not be added.
  @multiple_resources = false
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



7
8
9
# File 'lib/jets/cfn/resource/associated.rb', line 7

def definition
  @definition
end

#multiple_resourcesObject

Returns the value of attribute multiple_resources.



8
9
10
# File 'lib/jets/cfn/resource/associated.rb', line 8

def multiple_resources
  @multiple_resources
end

Instance Method Details

#attributesObject



27
28
29
# File 'lib/jets/cfn/resource/associated.rb', line 27

def attributes
  standardized.values.first
end

#logical_idObject



23
24
25
# File 'lib/jets/cfn/resource/associated.rb', line 23

def logical_id
  standardized.keys.first
end

#standardizedObject



31
32
33
34
# File 'lib/jets/cfn/resource/associated.rb', line 31

def standardized
  standardizer = Standardizer.new(definition)
  standardizer.standarize(definition) # doesnt camelize keys yet
end