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/filters.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.
305 306 307 |
# File 'lib/aws/templates/utils/contextualized/filters.rb', line 305 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.
303 304 305 |
# File 'lib/aws/templates/utils/contextualized/filters.rb', line 303 def override @override end |
Instance Method Details
#filter(_, memo, instance) ⇒ Object
309 310 311 312 313 314 315 316 317 318 |
# File 'lib/aws/templates/utils/contextualized/filters.rb', line 309 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 |