Class: Aws::Templates::Utils::Default::Definition

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(hsh, ctx) ⇒ Definition

Create wrapper object

Creates wrapper object with attached hash and context to evaluate lambdas in



73
74
75
76
# File 'lib/aws/templates/utils/default.rb', line 73

def initialize(hsh, ctx)
  @hash = hsh
  @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)



53
54
55
56
# File 'lib/aws/templates/utils/default.rb', line 53

def [](k)
  result = _process_value(@hash[k])
  result.respond_to?(:to_hash) ? self.class.new(result, @context) : result
end

#dependenciesObject



43
44
45
# File 'lib/aws/templates/utils/default.rb', line 43

def dependencies
  to_hash.dependencies
end

#dependency?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/aws/templates/utils/default.rb', line 39

def dependency?
  true
end

#include?(k) ⇒ Boolean

Check if the key is present in the hash

Returns:

  • (Boolean)


60
61
62
# File 'lib/aws/templates/utils/default.rb', line 60

def include?(k)
  @hash.include?(k)
end

#keysObject

Defined hash keys



29
30
31
# File 'lib/aws/templates/utils/default.rb', line 29

def keys
  @hash.keys
end

#to_hashObject

Transform to hash



35
36
37
# File 'lib/aws/templates/utils/default.rb', line 35

def to_hash
  _recurse_into(@hash)
end

#to_recursiveObject

The class already supports recursive concept so return self



65
66
67
# File 'lib/aws/templates/utils/default.rb', line 65

def to_recursive
  self
end