class AWS::Core::XML::RootFrame

Public Class Methods

new(rules) click to toggle source
Calls superclass method AWS::Core::XML::Frame::new
# File lib/aws/core/xml/root_frame.rb, line 20
def initialize rules
  @inflected = {}
  @indexes = {}
  setup_indexes(rules)
  super(self, nil, 'XML', rules)
end

Public Instance Methods

add_to_index(index_name, key, value) click to toggle source
# File lib/aws/core/xml/root_frame.rb, line 37
def add_to_index index_name, key, value
  @indexes[index_name] ||= {}
  @indexes[index_name][key] = value
end
build_child_frame(element_name) click to toggle source
# File lib/aws/core/xml/root_frame.rb, line 27
def build_child_frame element_name
  Frame.new(self, self, element_name, rules)
end
inflect(element_name) click to toggle source

The root frame maintains a cache of inflected element names.

# File lib/aws/core/xml/root_frame.rb, line 43
def inflect element_name
  @inflected[element_name] ||= Inflection.ruby_name(element_name).to_sym
end
value() click to toggle source
# File lib/aws/core/xml/root_frame.rb, line 31
def value
  value = @data.values.find{|v| v.is_a?(Hash) }
  value ||= {}
  value.merge(@indexes)
end

Protected Instance Methods

setup_indexes(rules) click to toggle source

recursively crawls the parser rules and looks for elements that index values. Adds an empty index for each of these.

# File lib/aws/core/xml/root_frame.rb, line 51
def setup_indexes rules
  if rules[:children]
    rules[:children].each_pair do |child_name,child_rules|
      if index = child_rules[:index]
        @indexes[index[:name]] = {}
      end
      setup_indexes(child_rules)
    end
  end
end