Class: MessagePack::Factory
- Inherits:
-
Object
- Object
- MessagePack::Factory
- Defined in:
- doclib/msgpack/factory.rb
Overview
MessagePack::Factory is a class to generate Packer and Unpacker which has same set of ext types.
Defined Under Namespace
Classes: Pool
Instance Method Summary collapse
-
#dump(obj, options = nil) ⇒ String
(also: #pack)
Serialize the passed value.
-
#initialize ⇒ Factory
constructor
Creates a MessagePack::Factory instance.
-
#load(data, options = nil) ⇒ Object
(also: #unpack)
Deserializes an object from the string or io and returns it.
-
#packer(*args) ⇒ Object
Creates a MessagePack::Packer instance, which has ext types already registered.
-
#pool(size = 1, **options) ⇒ Object
Creates a MessagePack::PooledFactory instance of the given size.
-
#register_type(type, klass, options = {}) ⇒ Object
Register a type and Class to be registered for packer and/or unpacker.
-
#registered_types(selector = :both) ⇒ Object
Returns a list of registered types, ordered by type id.
-
#type_registered?(klass_or_type, selector = :both) ⇒ Boolean
Returns true/false which indicate specified class or type id is registered or not.
-
#unpacker(*args) ⇒ Object
Creates a MessagePack::Unpacker instance, which has ext types already registered.
Constructor Details
#initialize ⇒ Factory
Creates a MessagePack::Factory instance
10 11 |
# File 'doclib/msgpack/factory.rb', line 10 def initialize end |
Instance Method Details
#dump(obj, options = nil) ⇒ String Also known as: pack
Serialize the passed value
If it could not serialize the object, it raises NoMethodError: undefined method `to_msgpack' for #<the_object>.
See Packer#initialize for supported options.
34 35 |
# File 'doclib/msgpack/factory.rb', line 34 def dump(obj, =nil) end |
#load(data, options = nil) ⇒ Object Also known as: unpack
Deserializes an object from the string or io and returns it.
If there're not enough data to deserialize one object, this method raises EOFError. If data format is invalid, this method raises MessagePack::MalformedFormatError. If the object nests too deeply, this method raises MessagePack::StackError.
See Unpacker#initialize for supported options.
60 61 |
# File 'doclib/msgpack/factory.rb', line 60 def load(data, =nil) end |
#packer(*args) ⇒ Object
Creates a MessagePack::Packer instance, which has ext types already registered. Options are passed to MessagePack::Packer#initialized.
See also Packer#initialize for options.
19 20 |
# File 'doclib/msgpack/factory.rb', line 19 def packer(*args) end |
#pool(size = 1, **options) ⇒ Object
Creates a MessagePack::PooledFactory instance of the given size.
PooledFactory keeps Packer and Unpacker instance in a pool for improved performance. Note that the size defines how many instances are kept in cache, not the maximum of instances that can be created. If the pool limit is reached, a new instance is created anyway.
113 114 |
# File 'doclib/msgpack/factory.rb', line 113 def pool(size=1, **) end |
#register_type(type, klass, options = {}) ⇒ Object
Register a type and Class to be registered for packer and/or unpacker. If options are not specified, factory will use :to_msgpack_ext for packer, and :from_msgpack_ext for unpacker.
Supported options:
-
:packer specify symbol or proc object for packer
-
:unpacker specify symbol or proc object for unpacker
-
:optimized_symbols_parsing specify true to use the optimized symbols parsing (not supported on JRuby now)
-
recursive specify true to receive the packer or unpacker as argument to generate the extension body manually.
81 82 |
# File 'doclib/msgpack/factory.rb', line 81 def register_type(type, klass, ={}) end |
#registered_types(selector = :both) ⇒ Object
Returns a list of registered types, ordered by type id.
90 91 |
# File 'doclib/msgpack/factory.rb', line 90 def registered_types(selector=:both) end |
#type_registered?(klass_or_type, selector = :both) ⇒ Boolean
Returns true/false which indicate specified class or type id is registered or not.
100 101 |
# File 'doclib/msgpack/factory.rb', line 100 def type_registered?(klass_or_type, selector=:both) end |
#unpacker(*args) ⇒ Object
Creates a MessagePack::Unpacker instance, which has ext types already registered. Options are passed to MessagePack::Unpacker#initialized.
See also Unpacker#initialize for options.
44 45 |
# File 'doclib/msgpack/factory.rb', line 44 def unpacker(*args) end |