Class: Aws::Templates::Utils::Parametrized::Getter::Path
- Inherits:
-
Aws::Templates::Utils::Parametrized::Getter
- Object
- Aws::Templates::Utils::Parametrized::Getter
- Aws::Templates::Utils::Parametrized::Getter::Path
- Defined in:
- lib/aws/templates/utils/parametrized/getter/path.rb
Overview
Lookup value in options by path
Looks up value from options attribute by specified path. The path can be either statically specified or a block can be provided. The block shouldn’t have parameters and should return an array containing path. The block will be executed in the instance context.
Example
class Piece
include Aws::Templates::Utils::Parametrized
parameter :param1, :getter => path(:a, :b)
end
i = Piece.new(:a => { :b => 3 })
i.param1 # => 3
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Path
constructor
A new instance of Path.
Methods inherited from Aws::Templates::Utils::Parametrized::Getter
Constructor Details
#initialize(path) ⇒ Path
Returns a new instance of Path.
29 30 31 32 33 34 35 36 37 |
# File 'lib/aws/templates/utils/parametrized/getter/path.rb', line 29 def initialize(path) unless path.respond_to?(:to_proc) || path.respond_to?(:to_a) raise ArgumentError.new( "Path can be either array or Proc: #{path.inspect}" ) end @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
27 28 29 |
# File 'lib/aws/templates/utils/parametrized/getter/path.rb', line 27 def path @path end |