class Aws::Templates::Utils::Parametrized::Getter::OneOf
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
Attributes
getters[R]
Public Class Methods
new(getters)
click to toggle source
# File lib/aws/templates/utils/parametrized/getter/one_of.rb, line 32 def initialize(getters) @getters = getters end
Protected Instance Methods
get(parameter, instance)
click to toggle source
# File lib/aws/templates/utils/parametrized/getter/one_of.rb, line 38 def get(parameter, instance) getters.lazy .map { |g| instance.instance_exec(parameter, &g) } .find { |v| !v.nil? } end