Class: Aws::Templates::Utils::Default::Definition
- 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(hsh, ctx) ⇒ Definition
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.
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 |
#dependencies ⇒ Object
43 44 45 |
# File 'lib/aws/templates/utils/default.rb', line 43 def dependencies to_hash.dependencies end |
#dependency? ⇒ 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
60 61 62 |
# File 'lib/aws/templates/utils/default.rb', line 60 def include?(k) @hash.include?(k) end |
#keys ⇒ Object
Defined hash keys
29 30 31 |
# File 'lib/aws/templates/utils/default.rb', line 29 def keys @hash.keys end |
#to_hash ⇒ Object
Transform to hash
35 36 37 |
# File 'lib/aws/templates/utils/default.rb', line 35 def to_hash _recurse_into(@hash) end |
#to_recursive ⇒ Object
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 |