class Aws::Templates::Utils::Parametrized::Getter::Value
Calculate value
If a block is specified, it will be executed in the instance context and return will be used as parameter value. If a value specified then it will be used as parameter value instead.
Example¶ ↑
class Piece include Aws::Templates::Utils::Parametrized parameter :param1, :getter => value(1) parameter :param2, :getter => value { options[:z] + 1 } end i = Piece.new(:z => 3) i.param2 # => 4 i.param1 # => 1
Attributes
calculation[R]
Public Class Methods
new(calculation)
click to toggle source
# File lib/aws/templates/utils/parametrized/getter/value.rb, line 30 def initialize(calculation) @calculation = calculation end
Protected Instance Methods
get(_, instance)
click to toggle source
# File lib/aws/templates/utils/parametrized/getter/value.rb, line 36 def get(_, instance) if calculation.respond_to?(:to_hash) calculation elsif calculation.respond_to?(:to_proc) instance.instance_eval(&calculation) else calculation end end