Class: Thrift::Types::Value::Value
- Inherits:
-
Union
- Object
- Union
- Thrift::Types::Value::Value
show all
- Includes:
- Struct_Union
- Defined in:
- lib/thrift/types/value/value.rb,
lib/thrift/types/value/value_types.rb,
lib/thrift/types/value/value_types.rb
Constant Summary
collapse
- NAME =
'Value'.freeze
- NAMESPACE =
'types.value'.freeze
- LEGACY_ANNOTATIONS =
{
}.freeze
- STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_INDEX_NULL_VALUE =
1
- THRIFT_FIELD_INDEX_STRING_VALUE =
2
- THRIFT_FIELD_INDEX_BINARY_VALUE =
3
- THRIFT_FIELD_INDEX_INTEGER_VALUE =
4
- THRIFT_FIELD_INDEX_DOUBLE_VALUE =
5
- THRIFT_FIELD_INDEX_BOOL_VALUE =
6
- THRIFT_FIELD_INDEX_LIST_VALUE =
7
- THRIFT_FIELD_INDEX_MAP_VALUE =
8
- THRIFT_FIELD_INDEX_STRUCT_VALUE =
9
- THRIFT_FIELD_NULL_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_NULL_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_STRING_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_STRING_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_BINARY_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_BINARY_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_INTEGER_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_INTEGER_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_DOUBLE_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_DOUBLE_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_BOOL_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_BOOL_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_LIST_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_LIST_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_MAP_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_MAP_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- THRIFT_FIELD_STRUCT_VALUE_LEGACY_ANNOTATIONS =
{
}.freeze
- THRIFT_FIELD_STRUCT_VALUE_STRUCTURED_ANNOTATIONS =
[
].freeze
- FIELDS =
{
THRIFT_FIELD_INDEX_NULL_VALUE => {type: ::Thrift::Types::STRUCT, name: 'null_value', class: ::Thrift::Types::Value::NullValue, optional: true, legacy_annotations: THRIFT_FIELD_NULL_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_NULL_VALUE_STRUCTURED_ANNOTATIONS},
THRIFT_FIELD_INDEX_STRING_VALUE => {type: ::Thrift::Types::STRING, name: 'string_value', optional: true, legacy_annotations: THRIFT_FIELD_STRING_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_STRING_VALUE_STRUCTURED_ANNOTATIONS},
THRIFT_FIELD_INDEX_BINARY_VALUE => {type: ::Thrift::Types::STRING, name: 'binary_value', binary: true, optional: true, legacy_annotations: THRIFT_FIELD_BINARY_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_BINARY_VALUE_STRUCTURED_ANNOTATIONS},
THRIFT_FIELD_INDEX_INTEGER_VALUE => {type: ::Thrift::Types::I64, name: 'integer_value', optional: true, legacy_annotations: THRIFT_FIELD_INTEGER_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_INTEGER_VALUE_STRUCTURED_ANNOTATIONS},
THRIFT_FIELD_INDEX_DOUBLE_VALUE => {type: ::Thrift::Types::DOUBLE, name: 'double_value', optional: true, legacy_annotations: THRIFT_FIELD_DOUBLE_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_DOUBLE_VALUE_STRUCTURED_ANNOTATIONS},
THRIFT_FIELD_INDEX_BOOL_VALUE => {type: ::Thrift::Types::BOOL, name: 'bool_value', optional: true, legacy_annotations: THRIFT_FIELD_BOOL_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_BOOL_VALUE_STRUCTURED_ANNOTATIONS},
THRIFT_FIELD_INDEX_LIST_VALUE => {type: ::Thrift::Types::STRUCT, name: 'list_value', class: ::Thrift::Types::Value::ListValue, optional: true, legacy_annotations: THRIFT_FIELD_LIST_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_LIST_VALUE_STRUCTURED_ANNOTATIONS},
THRIFT_FIELD_INDEX_MAP_VALUE => {type: ::Thrift::Types::STRUCT, name: 'map_value', class: ::Thrift::Types::Value::MapValue, optional: true, legacy_annotations: THRIFT_FIELD_MAP_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_MAP_VALUE_STRUCTURED_ANNOTATIONS},
THRIFT_FIELD_INDEX_STRUCT_VALUE => {type: ::Thrift::Types::STRUCT, name: 'struct_value', class: ::Thrift::Types::Value::StructValue, optional: true, legacy_annotations: THRIFT_FIELD_STRUCT_VALUE_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_STRUCT_VALUE_STRUCTURED_ANNOTATIONS}
}.freeze
Struct_Union::CONTAINER_TYPES
Class Method Summary
collapse
Instance Method Summary
collapse
#each_field, #field_info, #inspect_collection, #inspect_field, #is_container?, #name_to_id, #read_field, #sorted_field_ids, #write_container, #write_data
Methods inherited from Union
#<=>, #==, field_accessor, generate_accessors, #get_set_field, #get_value, #hash, #initialize, #inspect, qmark_isset_method, #read, #write
Constructor Details
This class inherits a constructor from Thrift::Union
Class Method Details
.binary_value(val) ⇒ Object
182
183
184
|
# File 'lib/thrift/types/value/value_types.rb', line 182
def binary_value(val)
Value.new(:binary_value, val)
end
|
.bool_value(val) ⇒ Object
194
195
196
|
# File 'lib/thrift/types/value/value_types.rb', line 194
def bool_value(val)
Value.new(:bool_value, val)
end
|
.double_value(val) ⇒ Object
190
191
192
|
# File 'lib/thrift/types/value/value_types.rb', line 190
def double_value(val)
Value.new(:double_value, val)
end
|
.integer_value(val) ⇒ Object
186
187
188
|
# File 'lib/thrift/types/value/value_types.rb', line 186
def integer_value(val)
Value.new(:integer_value, val)
end
|
.list_value(val) ⇒ Object
198
199
200
|
# File 'lib/thrift/types/value/value_types.rb', line 198
def list_value(val)
Value.new(:list_value, val)
end
|
.map_value(val) ⇒ Object
202
203
204
|
# File 'lib/thrift/types/value/value_types.rb', line 202
def map_value(val)
Value.new(:map_value, val)
end
|
.null_value(val) ⇒ Object
174
175
176
|
# File 'lib/thrift/types/value/value_types.rb', line 174
def null_value(val)
Value.new(:null_value, val)
end
|
.string_value(val) ⇒ Object
178
179
180
|
# File 'lib/thrift/types/value/value_types.rb', line 178
def string_value(val)
Value.new(:string_value, val)
end
|
.struct_value(val) ⇒ Object
206
207
208
|
# File 'lib/thrift/types/value/value_types.rb', line 206
def struct_value(val)
Value.new(:struct_value, val)
end
|
Instance Method Details
#struct_fields ⇒ Object
287
|
# File 'lib/thrift/types/value/value_types.rb', line 287
def struct_fields; FIELDS; end
|
#to_object ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/thrift/types/value/value.rb', line 68
def to_object
case get_value.class
when NullValue
nil
when ListValue
list_value.to_array
when MapValue
map_value.to_hash
when StructValue
struct_value.to_hash
else
get_value
end
end
|
#validate ⇒ Object
289
290
291
|
# File 'lib/thrift/types/value/value_types.rb', line 289
def validate
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
end
|