Module: Oplogjam::Sanitizer
- Defined in:
- lib/oplogjam/sanitizer.rb
Class Method Summary collapse
-
.sanitize(obj) ⇒ Object
Strip any null bytes from objects as they will be rejected by PostgreSQL.
Class Method Details
.sanitize(obj) ⇒ Object
Strip any null bytes from objects as they will be rejected by PostgreSQL
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/oplogjam/sanitizer.rb', line 4 def self.sanitize(obj) case obj when Sequel::Postgres::JSONBHash, Hash obj.each_with_object({}) do |(key, value), acc| acc[sanitize(key)] = sanitize(value) end when Sequel::Postgres::JSONBArray, Array obj.map { |element| sanitize(element) } when String obj.tr("\x00", '') else obj end end |