Module Thrift
In: lib/thrift/processor.rb
lib/thrift/union.rb
lib/thrift/server/threaded_server.rb
lib/thrift/server/mongrel_http_server.rb
lib/thrift/server/base_server.rb
lib/thrift/server/simple_server.rb
lib/thrift/server/nonblocking_server.rb
lib/thrift/server/thread_pool_server.rb
lib/thrift/struct.rb
lib/thrift/bytes.rb
lib/thrift/client.rb
lib/thrift/types.rb
lib/thrift/exceptions.rb
lib/thrift/struct_union.rb
lib/thrift/serializer/deserializer.rb
lib/thrift/serializer/serializer.rb
lib/thrift/protocol/compact_protocol.rb
lib/thrift/protocol/json_protocol.rb
lib/thrift/protocol/binary_protocol.rb
lib/thrift/protocol/binary_protocol_accelerated.rb
lib/thrift/protocol/base_protocol.rb
lib/thrift/transport/base_transport.rb
lib/thrift/transport/framed_transport.rb
lib/thrift/transport/unix_socket.rb
lib/thrift/transport/server_socket.rb
lib/thrift/transport/http_client_transport.rb
lib/thrift/transport/base_server_transport.rb
lib/thrift/transport/io_stream_transport.rb
lib/thrift/transport/buffered_transport.rb
lib/thrift/transport/memory_buffer_transport.rb
lib/thrift/transport/socket.rb
lib/thrift/transport/unix_server_socket.rb
lib/thrift/bytes.rb
lib/thrift/client.rb
lib/thrift/exceptions.rb
lib/thrift/processor.rb
lib/thrift/protocol/base_protocol.rb
lib/thrift/protocol/binary_protocol.rb
lib/thrift/protocol/binary_protocol_accelerated.rb
lib/thrift/protocol/compact_protocol.rb
lib/thrift/protocol/json_protocol.rb
lib/thrift/serializer/deserializer.rb
lib/thrift/serializer/serializer.rb
lib/thrift/server/base_server.rb
lib/thrift/server/mongrel_http_server.rb
lib/thrift/server/nonblocking_server.rb
lib/thrift/server/simple_server.rb
lib/thrift/server/thread_pool_server.rb
lib/thrift/server/threaded_server.rb
lib/thrift/struct.rb
lib/thrift/struct_union.rb
lib/thrift/transport/base_server_transport.rb
lib/thrift/transport/base_transport.rb
lib/thrift/transport/buffered_transport.rb
lib/thrift/transport/framed_transport.rb
lib/thrift/transport/http_client_transport.rb
lib/thrift/transport/io_stream_transport.rb
lib/thrift/transport/memory_buffer_transport.rb
lib/thrift/transport/server_socket.rb
lib/thrift/transport/socket.rb
lib/thrift/transport/unix_server_socket.rb
lib/thrift/transport/unix_socket.rb
lib/thrift/types.rb
lib/thrift/union.rb

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Methods

Classes and Modules

Module Thrift::Bytes
Module Thrift::Client
Module Thrift::MessageTypes
Module Thrift::Processor
Module Thrift::Struct
Module Thrift::Struct_Union
Module Thrift::TransportUtils
Module Thrift::Types
Class Thrift::ApplicationException
Class Thrift::BaseProtocol
Class Thrift::BaseProtocolFactory
Class Thrift::BaseServer
Class Thrift::BaseServerTransport
Class Thrift::BaseTransport
Class Thrift::BaseTransportFactory
Class Thrift::BinaryProtocol
Class Thrift::BinaryProtocolAcceleratedFactory
Class Thrift::BinaryProtocolFactory
Class Thrift::BufferedTransport
Class Thrift::BufferedTransportFactory
Class Thrift::CompactProtocol
Class Thrift::CompactProtocolFactory
Class Thrift::Deserializer
Class Thrift::Exception
Class Thrift::FramedTransport
Class Thrift::FramedTransportFactory
Class Thrift::HTTPClientTransport
Class Thrift::IOStreamTransport
Class Thrift::JSONContext
Class Thrift::JSONListContext
Class Thrift::JSONPairContext
Class Thrift::JsonProtocol
Class Thrift::JsonProtocolFactory
Class Thrift::LookaheadReader
Class Thrift::MemoryBufferTransport
Class Thrift::MongrelHTTPServer
Class Thrift::NonblockingServer
Class Thrift::ProtocolException
Class Thrift::Serializer
Class Thrift::ServerSocket
Class Thrift::SimpleServer
Class Thrift::Socket
Class Thrift::ThreadPoolServer
Class Thrift::ThreadedServer
Class Thrift::TransportException
Class Thrift::TypeError
Class Thrift::UNIXServerSocket
Class Thrift::UNIXSocket
Class Thrift::Union

Attributes

type_checking  [RW] 
type_checking  [RW] 

Public Class methods

[Source]

    # File lib/thrift/types.rb, line 46
46:   def self.check_type(value, field, name, skip_nil=true)
47:     return if value.nil? and skip_nil
48:     klasses = case field[:type]
49:               when Types::VOID
50:                 NilClass
51:               when Types::BOOL
52:                 [TrueClass, FalseClass]
53:               when Types::BYTE, Types::I16, Types::I32, Types::I64
54:                 Integer
55:               when Types::DOUBLE
56:                 Float
57:               when Types::STRING
58:                 String
59:               when Types::STRUCT
60:                 [Struct, Union]
61:               when Types::MAP
62:                 Hash
63:               when Types::SET
64:                 Set
65:               when Types::LIST
66:                 Array
67:               end
68:     valid = klasses && [*klasses].any? { |klass| klass === value }
69:     raise TypeError, "Expected #{type_name(field[:type])}, received #{value.class} for field #{name}" unless valid
70:     # check elements now
71:     case field[:type]
72:     when Types::MAP
73:       value.each_pair do |k,v|
74:         check_type(k, field[:key], "#{name}.key", false)
75:         check_type(v, field[:value], "#{name}.value", false)
76:       end
77:     when Types::SET, Types::LIST
78:       value.each do |el|
79:         check_type(el, field[:element], "#{name}.element", false)
80:       end
81:     when Types::STRUCT
82:       raise TypeError, "Expected #{field[:class]}, received #{value.class} for field #{name}" unless field[:class] == value.class
83:     end
84:   end

[Source]

    # File lib/thrift/types.rb, line 46
46:   def self.check_type(value, field, name, skip_nil=true)
47:     return if value.nil? and skip_nil
48:     klasses = case field[:type]
49:               when Types::VOID
50:                 NilClass
51:               when Types::BOOL
52:                 [TrueClass, FalseClass]
53:               when Types::BYTE, Types::I16, Types::I32, Types::I64
54:                 Integer
55:               when Types::DOUBLE
56:                 Float
57:               when Types::STRING
58:                 String
59:               when Types::STRUCT
60:                 [Struct, Union]
61:               when Types::MAP
62:                 Hash
63:               when Types::SET
64:                 Set
65:               when Types::LIST
66:                 Array
67:               end
68:     valid = klasses && [*klasses].any? { |klass| klass === value }
69:     raise TypeError, "Expected #{type_name(field[:type])}, received #{value.class} for field #{name}" unless valid
70:     # check elements now
71:     case field[:type]
72:     when Types::MAP
73:       value.each_pair do |k,v|
74:         check_type(k, field[:key], "#{name}.key", false)
75:         check_type(v, field[:value], "#{name}.value", false)
76:       end
77:     when Types::SET, Types::LIST
78:       value.each do |el|
79:         check_type(el, field[:element], "#{name}.element", false)
80:       end
81:     when Types::STRUCT
82:       raise TypeError, "Expected #{field[:class]}, received #{value.class} for field #{name}" unless field[:class] == value.class
83:     end
84:   end

[Source]

    # File lib/thrift/types.rb, line 86
86:   def self.type_name(type)
87:     Types.constants.each do |const|
88:       return "Types::#{const}" if Types.const_get(const) == type
89:     end
90:     nil
91:   end

[Source]

    # File lib/thrift/types.rb, line 86
86:   def self.type_name(type)
87:     Types.constants.each do |const|
88:       return "Types::#{const}" if Types.const_get(const) == type
89:     end
90:     nil
91:   end

[Validate]