Class: DefaultModelSerializer
- Inherits:
-
Object
- Object
- DefaultModelSerializer
- Defined in:
- lib/internal/serializer.rb
Constant Summary collapse
- Snapshot_Extension =
'snapshot'
Instance Method Summary collapse
- #dump(object_model) ⇒ Object
-
#initialize(iomanager, marshaller) ⇒ DefaultModelSerializer
constructor
A new instance of DefaultModelSerializer.
- #load ⇒ Object
Constructor Details
#initialize(iomanager, marshaller) ⇒ DefaultModelSerializer
Returns a new instance of DefaultModelSerializer.
5 6 7 |
# File 'lib/internal/serializer.rb', line 5 def initialize( iomanager, marshaller ) @iomanager, @marshaller = iomanager, marshaller end |
Instance Method Details
#dump(object_model) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/internal/serializer.rb', line 9 def dump( object_model ) begin stream = @iomanager.create_new_stream( Snapshot_Extension ) @marshaller.serialize_to_stream( object_model, stream ) ensure stream.close end end |
#load ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/internal/serializer.rb', line 18 def load() object_model = nil stream = @iomanager.obtain_latest_read_stream( Snapshot_Extension ) return nil if stream.nil? begin object_model = @marshaller.restore( stream ) ensure stream.close end object_model end |