Class: Restate::TypeSerde
- Inherits:
-
Object
- Object
- Restate::TypeSerde
- Defined in:
- lib/restate/serde.rb
Overview
Serde wrapper for primitive types and classes with a .json_schema method. Delegates serialize/deserialize to JsonSerde, adds schema.
Instance Attribute Summary collapse
-
#type_class ⇒ Object
readonly
Returns the value of attribute type_class.
Instance Method Summary collapse
-
#deserialize(buf) ⇒ Object
Deserialize JSON bytes to a Ruby object via JsonSerde.
-
#initialize(type, schema) ⇒ TypeSerde
constructor
Create a TypeSerde for the given type with a precomputed JSON Schema.
-
#json_schema ⇒ Object
Return the JSON Schema for this type.
-
#serialize(obj) ⇒ Object
Serialize a Ruby object to JSON bytes via JsonSerde.
Constructor Details
#initialize(type, schema) ⇒ TypeSerde
Create a TypeSerde for the given type with a precomputed JSON Schema.
154 155 156 157 |
# File 'lib/restate/serde.rb', line 154 def initialize(type, schema) @type_class = type @schema = schema end |
Instance Attribute Details
#type_class ⇒ Object (readonly)
Returns the value of attribute type_class.
151 152 153 |
# File 'lib/restate/serde.rb', line 151 def type_class @type_class end |
Instance Method Details
#deserialize(buf) ⇒ Object
Deserialize JSON bytes to a Ruby object via JsonSerde.
165 166 167 |
# File 'lib/restate/serde.rb', line 165 def deserialize(buf) JsonSerde.deserialize(buf) end |
#json_schema ⇒ Object
Return the JSON Schema for this type.
170 171 172 |
# File 'lib/restate/serde.rb', line 170 def json_schema @schema end |