Class: Skit::Serialization::Processor::Integer

Inherits:
Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/skit/serialization/processor/integer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #traverse

Constructor Details

This class inherits a constructor from Skit::Serialization::Processor::Base

Class Method Details

.handles?(type_spec) ⇒ Boolean

Returns:



11
12
13
# File 'lib/skit/serialization/processor/integer.rb', line 11

def self.handles?(type_spec)
  type_spec == ::Integer
end

Instance Method Details

#deserialize(value, path: Path.new) ⇒ Object

Raises:



23
24
25
26
27
# File 'lib/skit/serialization/processor/integer.rb', line 23

def deserialize(value, path: Path.new)
  raise DeserializeError.new("Expected Integer, got #{value.class}", path: path) unless value.is_a?(::Integer)

  value
end

#serialize(value, path: Path.new) ⇒ Object

Raises:



16
17
18
19
20
# File 'lib/skit/serialization/processor/integer.rb', line 16

def serialize(value, path: Path.new)
  raise SerializeError.new("Expected Integer, got #{value.class}", path: path) unless value.is_a?(::Integer)

  value
end