Class: Sqrewdriver::Serdes::JSONSerde

Inherits:
Object
  • Object
show all
Defined in:
lib/sqrewdriver/serdes/json_serde.rb

Defined Under Namespace

Classes: JSONWrapper

Instance Method Summary collapse

Constructor Details

#initialize(backend: :json, serialize_options: {}, deserialize_options: {}) ⇒ JSONSerde

Returns a new instance of JSONSerde.



14
15
16
17
18
# File 'lib/sqrewdriver/serdes/json_serde.rb', line 14

def initialize(backend: :json, serialize_options: {}, deserialize_options: {})
  @serialize_options = serialize_options
  @deserialize_options = deserialize_options
  @backend = lookup_json_backend(backend)
end

Instance Method Details

#dump(val) ⇒ Object



20
21
22
# File 'lib/sqrewdriver/serdes/json_serde.rb', line 20

def dump(val)
  @backend.dump(val, **@serialize_options)
end

#load(val) ⇒ Object



24
25
26
# File 'lib/sqrewdriver/serdes/json_serde.rb', line 24

def load(val)
  @backend.load(val, **@deserialize_options)
end