Class: Aws::Xml::Parser::StructureFrame Private

Inherits:
Frame
  • Object
show all
Defined in:
lib/aws-sdk-core/xml/parser/frame.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from Frame

#parent, #ref, #result

Instance Method Summary collapse

Methods inherited from Frame

new, #path, #set_text, #yield_unhandled_value

Constructor Details

#initialize(xml_name, parent, ref, result = nil) ⇒ StructureFrame

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of StructureFrame.



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/aws-sdk-core/xml/parser/frame.rb', line 82

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

Instance Method Details

#child_frame(xml_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



95
96
97
98
99
100
101
102
103
# File 'lib/aws-sdk-core/xml/parser/frame.rb', line 95

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

#consume_child_frame(child) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/aws-sdk-core/xml/parser/frame.rb', line 105

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