Class: Thrift::Types::Known::Any::Any
- Inherits:
-
Object
- Object
- Thrift::Types::Known::Any::Any
show all
- Includes:
- Struct, Struct_Union
- Defined in:
- lib/thrift/types/known/any.rb,
lib/thrift/types/known/any_types.rb,
lib/thrift/types/known/any_types.rb
Defined Under Namespace
Classes: CodecNotHandled, TypeNotHandled
Constant Summary
collapse
- NAME =
'Any'.freeze
- NAMESPACE =
'types.known.any'.freeze
- THRIFT_FIELD_INDEX_TYPE =
1
- THRIFT_FIELD_INDEX_VALUE =
2
- FIELDS =
{
THRIFT_FIELD_INDEX_TYPE => {type: ::Thrift::Types::STRING, name: 'type'},
THRIFT_FIELD_INDEX_VALUE => {type: ::Thrift::Types::STRING, name: 'value', binary: true}
}
Struct_Union::CONTAINER_TYPES
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Struct
#<=>, #==, #differences, #eql?, field_accessor, #fields_with_default_values, generate_accessors, #hash, #initialize, #inspect, qmark_isset_method, #read, #write
#each_field, #field_info, #inspect_collection, #inspect_field, #is_container?, #name_to_id, #read_field, #sorted_field_ids, #write_container, #write_data
Class Method Details
.from_object(obj, codec_key = '') ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/thrift/types/known/any.rb', line 132
def from_object(obj, codec_key = '')
struct_def = Thrift::STRUCT_DEFINITIONS.values.find do |v|
obj.is_a? v.klass
end
raise TypeNotHandled unless struct_def
raise CodecNotHandled unless CODECS[codec_key]
key = codec_key.eql?('') ? '' : "-#{codec_key}"
Any.new(
type: "thrift#{key}/#{struct_def.struct_type}",
value: CODECS[codec_key].encode(obj)
)
end
|
Instance Method Details
#struct_fields ⇒ Object
29
|
# File 'lib/thrift/types/known/any_types.rb', line 29
def struct_fields; FIELDS; end
|