Class: Skit::Serialization::Processor::SimpleType
- Extended by:
- T::Sig
- Defined in:
- lib/skit/serialization/processor/simple_type.rb
Class Method Summary collapse
Instance Method Summary collapse
- #deserialize(value, path: Path.new) ⇒ Object
-
#initialize(type_spec, registry:) ⇒ SimpleType
constructor
A new instance of SimpleType.
- #serialize(value, path: Path.new) ⇒ Object
- #traverse(value, path: Path.new, &blk) ⇒ Object
Constructor Details
#initialize(type_spec, registry:) ⇒ SimpleType
Returns a new instance of SimpleType.
16 17 18 19 20 21 22 23 |
# File 'lib/skit/serialization/processor/simple_type.rb', line 16 def initialize(type_spec, registry:) super unless type_spec.is_a?(T::Types::Simple) raise ArgumentError, "Expected T::Types::Simple, got #{type_spec.class}" end @raw_type = T.let(type_spec.raw_type, T.untyped) end |
Class Method Details
.handles?(type_spec) ⇒ Boolean
11 12 13 |
# File 'lib/skit/serialization/processor/simple_type.rb', line 11 def self.handles?(type_spec) type_spec.is_a?(T::Types::Simple) end |
Instance Method Details
#deserialize(value, path: Path.new) ⇒ Object
32 33 34 35 |
# File 'lib/skit/serialization/processor/simple_type.rb', line 32 def deserialize(value, path: Path.new) processor = @registry.processor_for(@raw_type) processor.deserialize(value, path: path) end |
#serialize(value, path: Path.new) ⇒ Object
26 27 28 29 |
# File 'lib/skit/serialization/processor/simple_type.rb', line 26 def serialize(value, path: Path.new) processor = @registry.processor_for(@raw_type) processor.serialize(value, path: path) end |
#traverse(value, path: Path.new, &blk) ⇒ Object
44 45 46 47 |
# File 'lib/skit/serialization/processor/simple_type.rb', line 44 def traverse(value, path: Path.new, &blk) processor = @registry.processor_for(@raw_type) processor.traverse(value, path: path, &blk) end |