Class: Stargate::Marshal::Marshaller
- Inherits:
-
Object
- Object
- Stargate::Marshal::Marshaller
- Defined in:
- lib/stargate/marshal/marshaller.rb
Overview
Internal: Use it in order to pack data for exchange. Marshaller is created per instance of registry version. It packs basic values and objects of registered classes into Stargate::Marshal::Payload wraps.
Instance Method Summary collapse
-
#initialize(registry_version) ⇒ Marshaller
constructor
Public: Constructor.
-
#marshal(obj) ⇒ Object
Public: Returns given object after marshalling.
Constructor Details
#initialize(registry_version) ⇒ Marshaller
Public: Constructor. Initializes marshaller for given registry version object.
7 8 9 |
# File 'lib/stargate/marshal/marshaller.rb', line 7 def initialize(registry_version) @registry_version = registry_version end |
Instance Method Details
#marshal(obj) ⇒ Object
Public: Returns given object after marshalling.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/stargate/marshal/marshaller.rb', line 12 def marshal(obj) case obj when String, Numeric, TrueClass, FalseClass, Float, BigDecimal, NilClass Payload.new(Payload::SIMPLE, obj) when Symbol Payload.new(Payload::SYMBOL, obj.to_s) when Hash Payload.new(Payload::HASH, marshal_hash(obj)) when Array Payload.new(Payload::LIST, marshal_list(obj)) else Payload.new(*marshal_complex_object(obj)) end end |