Class: Messagebus::Thrift::MessagePayload

Inherits:
Object
  • Object
show all
Includes:
Thrift::Struct, Thrift::Struct_Union
Defined in:
lib/messagebus/messagebus_types.rb

Constant Summary collapse

MESSAGEFORMAT =
1
STRINGPAYLOAD =
2
BINARYPAYLOAD =
3
FIELDS =
{
  MESSAGEFORMAT => {:type => ::Thrift::Types::I32, :name => 'messageFormat', :enum_class => Messagebus::Thrift::MessagePayloadType},
  STRINGPAYLOAD => {:type => ::Thrift::Types::STRING, :name => 'stringPayload', :optional => true},
  BINARYPAYLOAD => {:type => ::Thrift::Types::STRING, :name => 'binaryPayload', :binary => true, :optional => true}
}

Instance Method Summary collapse

Instance Method Details

#binary?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/messagebus/messagebus_types.rb', line 62

def binary?
  @messageFormat == Messagebus::Thrift::MessagePayloadType::BINARY
end

#json?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/messagebus/messagebus_types.rb', line 66

def json?
  @messageFormat == Messagebus::Thrift::MessagePayloadType::JSON
end

#string?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/messagebus/messagebus_types.rb', line 70

def string?
  @messageFormat == Messagebus::Thrift::MessagePayloadType::STRING
end

#struct_fieldsObject



60
# File 'lib/messagebus/messagebus_types.rb', line 60

def struct_fields; FIELDS; end

#validateObject

Raises:

  • (::Thrift::ProtocolException)


74
75
76
77
78
79
# File 'lib/messagebus/messagebus_types.rb', line 74

def validate
  raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field messageFormat is unset!') unless @messageFormat
  unless @messageFormat.nil? || Messagebus::Thrift::MessagePayloadType::VALID_VALUES.include?(@messageFormat)
    raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field messageFormat!')
  end
end