Method: Thrift::Union#write

Defined in:
lib/thrift/union.rb

#write(oprot) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/thrift/union.rb', line 69

def write(oprot)
  validate
  oprot.write_struct_begin(self.class.name)

  fid = self.name_to_id(@setfield.to_s)

  field_info = struct_fields[fid]
  type = field_info[:type]
  if is_container? type
    oprot.write_field_begin(@setfield, type, fid)
    write_container(oprot, @value, field_info)
    oprot.write_field_end
  else
    oprot.write_field(@setfield, type, fid, @value)
  end

  oprot.write_field_stop
  oprot.write_struct_end
end