Class: MessageBus::Codec::Oj

Inherits:
Base
  • Object
show all
Defined in:
lib/message_bus/codec/oj.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = { mode: :compat }) ⇒ Oj

Returns a new instance of Oj.



8
9
10
# File 'lib/message_bus/codec/oj.rb', line 8

def initialize(options = { mode: :compat })
  @options = options
end

Instance Method Details

#decode(payload) ⇒ Object



16
17
18
# File 'lib/message_bus/codec/oj.rb', line 16

def decode(payload)
  ::Oj.load(payload, @options)
end

#encode(hash) ⇒ Object



12
13
14
# File 'lib/message_bus/codec/oj.rb', line 12

def encode(hash)
  ::Oj.dump(hash, @options)
end