Class: Queuel::Serialization::Json::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/queuel/serialization/json.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Decoder

Returns a new instance of Decoder.



11
12
13
# File 'lib/queuel/serialization/json.rb', line 11

def initialize(body)
  @body = body.to_s
end

Class Method Details

.call(body) ⇒ Object



7
8
9
# File 'lib/queuel/serialization/json.rb', line 7

def self.call(body)
  new(body).decode
end

Instance Method Details

#decodeObject



15
16
17
18
19
# File 'lib/queuel/serialization/json.rb', line 15

def decode
  MultiJson.load @body, symbolize_keys: true
rescue MultiJson::LoadError
  raise SerializationError, "Error reading:\n#{@body}"
end