class Aws::Templates::Utils::Default::Instantiation
Hash wrapper
The hash wrapper does intermediate calculations of nested lambdas in the specified context as they are encountered
Public Class Methods
new(ent, ctx)
click to toggle source
Create wrapper object
Creates wrapper object with attached hash and context to evaluate lambdas in
# 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
Public Instance Methods
[](k)
click to toggle source
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)
# File lib/aws/templates/utils/default.rb, line 266 def [](k) result = _process_value(value[k]) Utils.recursive?(result) ? _new(result) : result end
dependencies()
click to toggle source
# File lib/aws/templates/utils/default.rb, line 256 def dependencies to_hash.dependencies end
dependency?()
click to toggle source
# File lib/aws/templates/utils/default.rb, line 252 def dependency? true end
include?(k)
click to toggle source
Check if the key is present in the hash
# File lib/aws/templates/utils/default.rb, line 273 def include?(k) value.include?(k) end
keys()
click to toggle source
Defined hash keys
# File lib/aws/templates/utils/default.rb, line 242 def keys value.keys end
to_hash()
click to toggle source
Transform to hash
# File lib/aws/templates/utils/default.rb, line 248 def to_hash _recurse_into(value) end
to_recursive()
click to toggle source
The class already supports recursive concept so return self
# File lib/aws/templates/utils/default.rb, line 278 def to_recursive self end
value()
click to toggle source
# 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
Private Instance Methods
_new(ent)
click to toggle source
# File lib/aws/templates/utils/default.rb, line 298 def _new(ent) self.class.new(ent, @context) end
_process_value(value)
click to toggle source
# File lib/aws/templates/utils/default.rb, line 294 def _process_value(value) value.override? || Utils.recursive?(value) ? value : value.to_definition.for(@context) end
_recurse_into(value)
click to toggle source
# File lib/aws/templates/utils/default.rb, line 302 def _recurse_into(value) value.keys.each_with_object({}) do |k, memo| processed = _process_value(value[k]) processed = _recurse_into(processed) if Utils.recursive?(processed) memo[k] = processed end end