Module: Postjob::Queue::Encoder
Overview
The Postjob::Queue::Encoder module wraps the JSON encoder, to ensure that only our data is encoded.
Workflows should exclusively use Numbers, true, false, nil, Strings, Times and Dates, and Arrays and Hashes built of those.
postjob does not support all data types supported by Ruby’s “json” library. We do not support Symbols, but might also not support things like ActiveRecord objects etc.
Instance Method Summary collapse
Instance Method Details
#check_encodable!(data) ⇒ Object
19 20 21 |
# File 'lib/postjob/queue/encoder.rb', line 19 def check_encodable!(data) encode(data) end |
#encode(data) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/postjob/queue/encoder.rb', line 23 def encode(data) return nil if data.nil? verify_encodable!(data) ::JSON.generate(data) rescue ::JSON::JSONError, ::EncodingError raise ::Postjob::Error::Encoding, $!.to_s end |