Class: Synapse::Serialization::LazyObject
- Inherits:
-
Object
- Object
- Synapse::Serialization::LazyObject
- Defined in:
- lib/synapse/serialization/lazy_object.rb
Overview
Provides a generic lazy deserializing object
Instance Attribute Summary collapse
- #serialized_object ⇒ SerializedObject readonly
- #serializer ⇒ Serializer readonly
- #type ⇒ Class readonly
Instance Method Summary collapse
-
#deserialized ⇒ Object
Returns the deserialized version of the contained serialized object.
-
#deserialized? ⇒ Boolean
Returns true if this object has been deserialized already.
- #initialize(serialized_object, serializer) ⇒ undefined constructor
Constructor Details
#initialize(serialized_object, serializer) ⇒ undefined
17 18 19 20 21 |
# File 'lib/synapse/serialization/lazy_object.rb', line 17 def initialize(serialized_object, serializer) @serialized_object = serialized_object @serializer = serializer @type = serializer.class_for serialized_object.type end |
Instance Attribute Details
#serialized_object ⇒ SerializedObject (readonly)
6 7 8 |
# File 'lib/synapse/serialization/lazy_object.rb', line 6 def serialized_object @serialized_object end |
#serializer ⇒ Serializer (readonly)
9 10 11 |
# File 'lib/synapse/serialization/lazy_object.rb', line 9 def serializer @serializer end |
#type ⇒ Class (readonly)
12 13 14 |
# File 'lib/synapse/serialization/lazy_object.rb', line 12 def type @type end |
Instance Method Details
#deserialized ⇒ Object
Returns the deserialized version of the contained serialized object
25 26 27 |
# File 'lib/synapse/serialization/lazy_object.rb', line 25 def deserialized @deserialized ||= @serializer.deserialize @serialized_object end |
#deserialized? ⇒ Boolean
Returns true if this object has been deserialized already
31 32 33 |
# File 'lib/synapse/serialization/lazy_object.rb', line 31 def deserialized? !!@deserialized end |