Class: Jets::Resource
- Inherits:
-
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
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(definition, replacements = {}) ⇒ Resource
Returns a new instance of Resource.
5
6
7
8
|
# File 'lib/jets/resource.rb', line 5
def initialize(definition, replacements={})
@definition = definition
@replacements = replacements
end
|
Instance Attribute Details
#definition ⇒ Object
Returns the value of attribute definition.
4
5
6
|
# File 'lib/jets/resource.rb', line 4
def definition
@definition
end
|
#replacements ⇒ Object
Returns the value of attribute replacements.
4
5
6
|
# File 'lib/jets/resource.rb', line 4
def replacements
@replacements
end
|
Class Method Details
.truncate_id(id, postfix = '') ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/jets/resource.rb', line 29
def self.truncate_id(id, postfix = '')
if id.size + postfix.size > 62
"#{id[0..(55 - postfix.size)]}#{Digest::MD5.hexdigest(id)[0..5]}#{postfix}"
else
"#{id}#{postfix}"
end
end
|
Instance Method Details
#attributes ⇒ Object
48
49
50
51
52
|
# File 'lib/jets/resource.rb', line 48
def attributes
attributes = template.values.first
attributes = replacer.replace_placeholders(attributes)
Jets::Camelizer.transform(attributes)
end
|
#logical_id ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/jets/resource.rb', line 20
def logical_id
id = template.keys.first
id = replacer.replace_value(id)
id = Jets::Camelizer.camelize(id)
Jets::Resource.truncate_id(id)
end
|
#outputs ⇒ Object
58
59
60
|
# File 'lib/jets/resource.rb', line 58
def outputs
{}
end
|
#parameters ⇒ Object
54
55
56
|
# File 'lib/jets/resource.rb', line 54
def parameters
{}
end
|
#permission ⇒ Object
67
68
69
|
# File 'lib/jets/resource.rb', line 67
def permission
Permission.new(replacements, self)
end
|
#properties ⇒ Object
44
45
46
|
# File 'lib/jets/resource.rb', line 44
def properties
attributes['Properties']
end
|
#replacer ⇒ Object
62
63
64
|
# File 'lib/jets/resource.rb', line 62
def replacer
Replacer.new(replacements)
end
|
#standarize(*definition) ⇒ Object
16
17
18
|
# File 'lib/jets/resource.rb', line 16
def standarize(*definition)
Standardizer.new(definition).template
end
|
#template ⇒ Object
10
11
12
|
# File 'lib/jets/resource.rb', line 10
def template
standarize(definition)
end
|
#type ⇒ Object
40
41
42
|
# File 'lib/jets/resource.rb', line 40
def type
attributes['Type']
end
|