Class: Aws::Templates::Utils::Contextualized::Filter::Override
- Inherits:
-
Aws::Templates::Utils::Contextualized::Filter
- Object
- Aws::Templates::Utils::Contextualized::Filter
- Aws::Templates::Utils::Contextualized::Filter::Override
- Defined in:
- lib/aws/templates/utils/contextualized/filter/override.rb
Overview
Override specified keys in options hash
The filter performs merge the hash passed at initialization with options hash. Either hash itself or block returning a hash can be specified. The block will be evaluated in instance context so all instance methods are accessible.
Example
class Piece
include Aws::Templates::Utils::Contextualized
contextualize filter(:copy) & filter(:override, a: 12, b: 15, c: { d: 30 })
end
i = Piece.new
opts = Options.new(c: { e: 1 })
opts.filter(i.filter) # => { a: 12, b: 15, c: { d: 30, e: 1 } }
Instance Attribute Summary collapse
-
#override ⇒ Object
readonly
Returns the value of attribute override.
Instance Method Summary collapse
- #filter(_, memo, instance) ⇒ Object
-
#initialize(override = nil, &override_block) ⇒ Override
constructor
A new instance of Override.
Methods inherited from Aws::Templates::Utils::Contextualized::Filter
Constructor Details
#initialize(override = nil, &override_block) ⇒ Override
Returns a new instance of Override.
32 33 34 |
# File 'lib/aws/templates/utils/contextualized/filter/override.rb', line 32 def initialize(override = nil, &override_block) @override = _check_override_type(override || override_block) end |
Instance Attribute Details
#override ⇒ Object (readonly)
Returns the value of attribute override.
30 31 32 |
# File 'lib/aws/templates/utils/contextualized/filter/override.rb', line 30 def override @override end |
Instance Method Details
#filter(_, memo, instance) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/aws/templates/utils/contextualized/filter/override.rb', line 36 def filter(_, memo, instance) Utils.merge( memo, if override.respond_to?(:to_hash) override elsif override.respond_to?(:to_proc) instance.instance_eval(&override) end ) end |