class Thrift::Types::Value::Value

Constants

FIELDS
NAME
NAMESPACE
THRIFT_FIELD_INDEX_BINARY_VALUE
THRIFT_FIELD_INDEX_BOOL_VALUE
THRIFT_FIELD_INDEX_DOUBLE_VALUE
THRIFT_FIELD_INDEX_INTEGER_VALUE
THRIFT_FIELD_INDEX_LIST_VALUE
THRIFT_FIELD_INDEX_MAP_VALUE
THRIFT_FIELD_INDEX_NULL_VALUE
THRIFT_FIELD_INDEX_STRING_VALUE
THRIFT_FIELD_INDEX_STRUCT_VALUE

Public Class Methods

binary_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
150 def binary_value(val)
151   Value.new(:binary_value, val)
152 end
bool_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
162 def bool_value(val)
163   Value.new(:bool_value, val)
164 end
double_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
158 def double_value(val)
159   Value.new(:double_value, val)
160 end
from_object(v) click to toggle source
    # File lib/thrift/types/value.rb
 84 def from_object(v)
 85   case v
 86   when NilClass
 87     Value.new(null_value: NullValue.new)
 88   when Symbol
 89     Value.new(string_value: v.to_s)
 90   when String
 91     if v.encoding.eql?(Encoding::UTF_8) && v.valid_encoding?
 92       Value.new(string_value: v)
 93     else
 94       Value.new(binary_value: v)
 95     end
 96   when Integer
 97     Value.new(integer_value: v)
 98   when Float
 99     Value.new(double_value: v)
100   when TrueClass, FalseClass
101     Value.new(bool_value: v)
102   when Array
103     Value.new(list_value: ListValue.from_array(v))
104   when Hash
105     Value.new(map_value: MapValue.from_hash(v))
106   else
107     Value.new(struct_value: StructValue.from_object(v))
108   end
109 end
integer_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
154 def integer_value(val)
155   Value.new(:integer_value, val)
156 end
list_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
166 def list_value(val)
167   Value.new(:list_value, val)
168 end
map_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
170 def map_value(val)
171   Value.new(:map_value, val)
172 end
null_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
142 def null_value(val)
143   Value.new(:null_value, val)
144 end
string_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
146 def string_value(val)
147   Value.new(:string_value, val)
148 end
struct_value(val) click to toggle source
    # File lib/thrift/types/value_types.rb
174 def struct_value(val)
175   Value.new(:struct_value, val)
176 end

Public Instance Methods

struct_fields() click to toggle source
    # File lib/thrift/types/value_types.rb
201 def struct_fields; FIELDS; end
to_object() click to toggle source
   # File lib/thrift/types/value.rb
68 def to_object
69   case get_value.class
70   when NullValue
71      nil
72   when ListValue
73     list_value.to_array
74   when MapValue
75     map_value.to_hash
76   when StructValue
77     struct_value.to_hash
78   else
79     get_value
80   end
81 end
validate() click to toggle source
    # File lib/thrift/types/value_types.rb
203 def validate
204   raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
205 end