class Aws::Xml::Parser::StructureFrame
def apply_default_value(name, ref)
def apply_default_value(name, ref) case ref.shape when ListShape then @result[name] = DefaultList.new when MapShape then @result[name] = DefaultMap.new end end
def child_frame(xml_name)
def child_frame(xml_name) if @member = @members[xml_name] Frame.new(xml_name, self, @member[:ref]) elsif @ref.shape.union UnknownMemberFrame.new(xml_name, self, nil, @result) else NullFrame.new(xml_name, self) end end
def consume_child_frame(child)
def consume_child_frame(child) case child when MapEntryFrame @result[@member[:name]][child.key.result] = child.value.result when FlatListFrame @result[@member[:name]] << child.result when UnknownMemberFrame @result[:unknown] = { 'name' => child.path.last, 'value' => child.result } when NullFrame else @result[@member[:name]] = child.result end if @ref.shape.union # a union may only have one member set # convert to the union subclass # The default Struct created will have defaults set for all values # This also sets only one of the values leaving everything else nil # as required for unions set_member_name = @member ? @member[:name] : :unknown member_subclass = @ref.shape.member_subclass(set_member_name).new # shape.member_subclass(target.member).new member_subclass[set_member_name] = @result[set_member_name] @result = member_subclass end end
def flattened_list?(ref)
def flattened_list?(ref) ListShape === ref.shape && (ref.shape.flattened || ref["flattened"]) end
def initialize(xml_name, parent, ref, result = nil)
def initialize(xml_name, parent, ref, result = nil) super @result ||= ref.shape.struct_class.new @members = {} ref.shape.members.each do |member_name, member_ref| apply_default_value(member_name, member_ref) @members[xml_name(member_ref)] = { name: member_name, ref: member_ref, } end end
def xml_name(ref)
def xml_name(ref) if flattened_list?(ref) ref.shape.member.location_name || ref.location_name else ref.location_name end end