class AWS::Core::XmlGrammar::StubResponse

@private

def add_child_elements_to_context customizations, context

def add_child_elements_to_context customizations, context
  without_wrapper(customizations) do |child_name,child_rules|
    ruby_name = Inflection.ruby_name(child_rules[:renamed] || child_name)
    # we stop at any collected elements
    if child_rules[:collected]
      MetaUtils.extend_method(context, ruby_name) { [] }
      next
    end
    if child_rules[:construct_value] 
      
      MetaUtils.extend_method(context, ruby_name) do
        child_rules[:construct_value].call
      end
    elsif child_rules[:children].empty? # has no child elements
      unless child_rules[:ignored]
        method_name = child_rules[:boolean] ? "#{ruby_name}?" : ruby_name
        
        MetaUtils.extend_method(context, method_name) do
          if child_rules[:value_formatter]
            child_rules[:value_formatter].format_value('')
          else
            nil
          end
        end
      end
    else # it has one or more child elements
      if child_rules[:ignored]
        stub_methods(child_rules, context)
      else
        MetaUtils.extend_method(context, ruby_name) do
          StubResponse.new(child_rules)
        end
      end
    end
  end
end

def add_indexes_to_context(customizations, context)

Other tags:
    Private: -
def add_indexes_to_context(customizations, context)
  if indexes = customizations[:index_names]
    indexes.each do |index|
      MetaUtils.extend_method(context, index) { {} }
    end
  end
end

def add_wrappers_to_context customizations, context

def add_wrappers_to_context customizations, context
  wrappers(customizations) do |wrapper_name,wrapper_customizations|
    MetaUtils.extend_method(context, wrapper_name) do
      StubResponse.new(wrapper_customizations)
    end
  end
end

def initialize customizations, context = nil

def initialize customizations, context = nil
  @customizations = customizations
  stub_methods(customizations, context || self)
end

def inspect

def inspect
  methods = public_methods - Object.public_methods
  "<Stub #{methods.collect{|m| ":#{m}" }.sort.join(', ')}>" 
end

def stub_methods customizations, context

def stub_methods customizations, context
  add_wrappers_to_context(customizations, context)
  add_child_elements_to_context(customizations, context)
  add_indexes_to_context(customizations, context)
end

def without_wrapper customizations, &block

def without_wrapper customizations, &block
  customizations[:children].each_pair do |child_name,child_rules|
    unless child_rules[:wrapper]
      yield(child_name, child_rules)
    end
  end
end

def wrappers customizations, &block

Other tags:
    Private: -
def wrappers customizations, &block
  wrappers = {}
  customizations[:children].each_pair do |child_name,child_rules|
    if child_rules[:wrapper]
      wrapper_name = child_rules[:wrapper].first
      wrappers[wrapper_name] ||= { :children => {} }
      wrappers[wrapper_name][:children][child_name] = child_rules.merge(:wrapper => nil)
    end
  end
  wrappers.each_pair do |wrapper_name, wrapper_customizations|
    yield(wrapper_name, wrapper_customizations)
  end
end