module Aws::Resources::RequestParams::Param
Attributes
target[R]
@return [String] target
Public Class Methods
new(options)
click to toggle source
# File lib/aws-sdk-resources/request_params.rb, line 49 def initialize(options) @target = options[:target].to_s @steps = [] @target.scan(/\w+|\[\]|\[\*\]|\[[0-9]+\]/) do |step| case step when /\[\d+\]/ then @steps += [:array, step[1..-2].to_i] when /\[\*\]/ then @steps += [:array, :n] when '[]' then @steps += [:array, -1] else @steps += [:hash, step.to_sym] end end @steps.shift @final = @steps.pop end
Public Instance Methods
apply(params, options = {})
click to toggle source
# File lib/aws-sdk-resources/request_params.rb, line 67 def apply(params, options = {}) if @final == -1 build_context(params, options[:n]) << value(options) else build_context(params, options[:n])[@final] = value(options) end params end
Private Instance Methods
build_context(params, n)
click to toggle source
# File lib/aws-sdk-resources/request_params.rb, line 78 def build_context(params, n) @steps.each_slice(2).inject(params) do |context, (key, type)| entry = type == :array ? [] : {} if key == -1 context << entry entry elsif key == :n context[n] ||= entry else context[key] ||= entry end end end