Class: Aws::Templates::Utils::Contextualized::Filter::Copy

Inherits:
Aws::Templates::Utils::Contextualized::Filter show all
Defined in:
lib/aws/templates/utils/contextualized/filter/copy.rb

Overview

Add all options into the context

The filter performs deep copy of entire options hash with consecutive merge into the resulting context

Example

class Piece
  contextualize filter(:copy)
end

i = Piece.new()
opts = Options.new(a: { q: 1 }, b: 2, c: { d: { r: 5 }, e: 1 })
opts.filter(i.filter) # => { a: { q: 1 }, b: 2, c: { d: { r: 5 }, e: 1 } }

Constant Summary collapse

PRE_FILTER =
%i[label root parent meta].freeze

Instance Method Summary collapse

Methods inherited from Aws::Templates::Utils::Contextualized::Filter

#&, #to_filter, #to_proc

Instance Method Details

#filter(opts, memo, _) ⇒ Object



28
29
30
31
32
# File 'lib/aws/templates/utils/contextualized/filter/copy.rb', line 28

def filter(opts, memo, _)
  result = Utils.deep_dup(opts.to_hash)
  PRE_FILTER.each { |k| result.delete(k) }
  Utils.merge(memo, result)
end