Class: Jets::Resource

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/jets/resource/base.rb,
lib/jets/resource.rb,
lib/jets/resource/replacer.rb,
lib/jets/resource/associated.rb,
lib/jets/resource/permission.rb,
lib/jets/resource/standardizer.rb

Overview

Does not do full expansion, mainly a container that holds the definition and standardizes it without camelizing it.

Defined Under Namespace

Modules: ApiGateway, ChildStack, Config, Events, Iam, Iot, Lambda, Logs, Route53, S3, Sns, Sqs Classes: Associated, Base, Permission, Replacer, Standardizer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition, replacements = {}) ⇒ Resource

Returns a new instance of Resource.



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

def initialize(definition, replacements={})
  @definition = definition
  @replacements = replacements
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



22
23
24
# File 'lib/jets/resource.rb', line 22

def definition
  @definition
end

#replacementsObject (readonly)

Returns the value of attribute replacements.



22
23
24
# File 'lib/jets/resource.rb', line 22

def replacements
  @replacements
end

Instance Method Details

#attributesObject



53
54
55
56
57
# File 'lib/jets/resource.rb', line 53

def attributes
  attributes = template.values.first
  attributes = replacer.replace_placeholders(attributes)
  Jets::Camelizer.transform(attributes)
end

#logical_idObject



38
39
40
41
42
43
# File 'lib/jets/resource.rb', line 38

def logical_id
  id = template.keys.first
  # replace possible {namespace} in the logical id
  id = replacer.replace_value(id)
  Jets::Camelizer.camelize(id)
end

#outputsObject



63
64
65
# File 'lib/jets/resource.rb', line 63

def outputs
  {}
end

#parametersObject



59
60
61
# File 'lib/jets/resource.rb', line 59

def parameters
  {}
end

#permissionObject



72
73
74
# File 'lib/jets/resource.rb', line 72

def permission
  Permission.new(replacements, self)
end

#propertiesObject



49
50
51
# File 'lib/jets/resource.rb', line 49

def properties
  attributes['Properties']
end

#replacerObject



67
68
69
# File 'lib/jets/resource.rb', line 67

def replacer
  Replacer.new(replacements)
end

#standarize(*definition) ⇒ Object

CloudFormation Resources reference: amzn.to/2NKg6ip



34
35
36
# File 'lib/jets/resource.rb', line 34

def standarize(*definition)
  Standardizer.new(definition).template
end

#templateObject



28
29
30
# File 'lib/jets/resource.rb', line 28

def template
  standarize(definition)
end

#typeObject



45
46
47
# File 'lib/jets/resource.rb', line 45

def type
  attributes['Type']
end