Created
May 26, 2016 16:06
-
-
Save toch/b287a1f120898da06d76e0479fe0bc98 to your computer and use it in GitHub Desktop.
A Hanami Coercer for PG JSONB Datatype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "hanami/model/coercer" | |
require "sequel" | |
require "sequel/extensions/pg_json" | |
class PGJsonB < Hanami::Model::Coercer | |
def self.dump(hash_map) | |
::Sequel.pg_jsonb(hash_map) | |
end | |
def self.load(jsonb) | |
jsonb.to_hash unless jsonb.nil? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment