Class: Aws::Templates::Utils::Parametrized::Getter::OneOf

Inherits:
Aws::Templates::Utils::Parametrized::Getter show all
Defined in:
lib/aws/templates/utils/parametrized/getter/one_of.rb

Overview

Pick one of non-nil values returned by nested getters

In general it plays the same role as || operator in Ruby. It just picks first non-nil value returned by a list of getters

Example

class Piece
  include Aws::Templates::Utils::Parametrized

  parameter :param1, :getter => one_of(
    path(:a, :b),
    path(:b, :c)
  )
end

i = Piece.new( :a => { :b => 3 } )
i.param1 # => 3
i = Piece.new( :b => { :c => 4 } )
i.param1 # => 4

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Aws::Templates::Utils::Parametrized::Getter

#get_wrapper, #to_proc

Constructor Details

#initialize(getters) ⇒ OneOf

Returns a new instance of OneOf.



32
33
34
# File 'lib/aws/templates/utils/parametrized/getter/one_of.rb', line 32

def initialize(getters)
  @getters = getters
end

Instance Attribute Details

#gettersObject (readonly)

Returns the value of attribute getters.



30
31
32
# File 'lib/aws/templates/utils/parametrized/getter/one_of.rb', line 30

def getters
  @getters
end