Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Adrien Rey-Jarthon jarthod

🏠
Working from home
View GitHub Profile
@jarthod
jarthod / compressed.rb
Last active Jul 22, 2020 — forked from romanbsd/compressed.rb
Compressed fields in Mongoid 6.4
View compressed.rb
require 'zlib'
class CompressedString < String
def mongoize
BSON::Binary.new(Zlib::Deflate.deflate(self))
end
class << self
# Get the object as it was stored in the database, and instantiate
# this custom class from it.