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

Inherits:
Aws::Templates::Utils::Parametrized::Getter show all
Defined in:
lib/aws/templates/utils/parametrized/getters.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.



185
186
187
# File 'lib/aws/templates/utils/parametrized/getters.rb', line 185

def initialize(getters)
  @getters = getters
end

Instance Attribute Details

#gettersObject (readonly)

Returns the value of attribute getters.



183
184
185
# File 'lib/aws/templates/utils/parametrized/getters.rb', line 183

def getters
  @getters
end