Class: Aws::Templates::Utils::Default::Instantiation

Inherits:
Object
  • Object
show all
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

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

#dependenciesObject



256
257
258
# File 'lib/aws/templates/utils/default.rb', line 256

def dependencies
  to_hash.dependencies
end

#dependency?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


273
274
275
# File 'lib/aws/templates/utils/default.rb', line 273

def include?(k)
  value.include?(k)
end

#keysObject

Defined hash keys



242
243
244
# File 'lib/aws/templates/utils/default.rb', line 242

def keys
  value.keys
end

#to_hashObject

Transform to hash



248
249
250
# File 'lib/aws/templates/utils/default.rb', line 248

def to_hash
  _recurse_into(value)
end

#to_recursiveObject

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

#valueObject



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