Class: RightSupport::Data::UnknownType

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/right_support/data/unknown_type.rb

Overview

A type that can be instantiated by the DataSerializer (or anyone else) when an unknown Ruby type is encountered in serialized data. It functions like an OpenStruct, but it has a distinct type identity so the DataSerializer can work with it.

UnknownType remembers the original Ruby type name of the serialized object so it can be dumped back to a serialization stream without losing type identity or attribute information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(typename, attributes) ⇒ UnknownType

Construct a new object representing a serialized object of unknown type.

Parameters:

  • typename (String)
  • attributes (Hash)


38
39
40
41
# File 'lib/right_support/data/unknown_type.rb', line 38

def initialize(typename, attributes)
  @__typename__ = typename
  super(attributes)
end

Instance Attribute Details

#__typename__Object (readonly)

Returns the value of attribute __typename__.



33
34
35
# File 'lib/right_support/data/unknown_type.rb', line 33

def __typename__
  @__typename__
end