Class: Aws::Templates::Utils::Default::Instantiation
- Inherits:
-
Object
- Object
- Aws::Templates::Utils::Default::Instantiation
- Defined in:
- lib/aws/templates/utils/default.rb
Overview
Hash wrapper
The hash wrapper does intermediate calculations of nested lambdas in the specified context as they are encountered
Instance Method Summary collapse
-
#[](k) ⇒ Object
Index operator.
- #dependencies ⇒ Object
- #dependency? ⇒ Boolean
-
#include?(k) ⇒ Boolean
Check if the key is present in the hash.
-
#initialize(ent, ctx) ⇒ Instantiation
constructor
Create wrapper object.
-
#keys ⇒ Object
Defined hash keys.
-
#to_hash ⇒ Object
Transform to hash.
-
#to_recursive ⇒ Object
The class already supports recursive concept so return self.
- #value ⇒ Object
Constructor Details
#initialize(ent, ctx) ⇒ Instantiation
Create wrapper object
Creates wrapper object with attached hash and context to evaluate lambdas in
286 287 288 289 290 |
# File 'lib/aws/templates/utils/default.rb', line 286 def initialize(ent, ctx) raise "#{ent.inspect} is not recursive" if ent.override? @entry = ent @context = ctx end |
Instance Method Details
#[](k) ⇒ Object
Index operator
Performs intermediate transformation of value if needed (if value is a lambda) and returns it wrapping into Definition instance with the same context if needed (if value is a map)
266 267 268 269 |
# File 'lib/aws/templates/utils/default.rb', line 266 def [](k) result = _process_value(value[k]) Utils.recursive?(result) ? _new(result) : result end |
#dependencies ⇒ Object
256 257 258 |
# File 'lib/aws/templates/utils/default.rb', line 256 def dependencies to_hash.dependencies end |
#dependency? ⇒ Boolean
252 253 254 |
# File 'lib/aws/templates/utils/default.rb', line 252 def dependency? true end |
#include?(k) ⇒ Boolean
Check if the key is present in the hash
273 274 275 |
# File 'lib/aws/templates/utils/default.rb', line 273 def include?(k) value.include?(k) end |
#keys ⇒ Object
Defined hash keys
242 243 244 |
# File 'lib/aws/templates/utils/default.rb', line 242 def keys value.keys end |
#to_hash ⇒ Object
Transform to hash
248 249 250 |
# File 'lib/aws/templates/utils/default.rb', line 248 def to_hash _recurse_into(value) end |
#to_recursive ⇒ Object
The class already supports recursive concept so return self
278 279 280 |
# File 'lib/aws/templates/utils/default.rb', line 278 def to_recursive self end |
#value ⇒ Object
233 234 235 236 237 238 |
# File 'lib/aws/templates/utils/default.rb', line 233 def value return @value if @value @value = @entry.to_definition.for(@context) raise "#{@value.inspect} is not recursive" if @value.override? @value end |