Sha256: 1240a77b747746358be54f869e8cea26f3c76256dcf6bb76f69e67ae1e37c2ee
Contents?: true
Size: 659 Bytes
Versions: 4
Compression:
Stored size: 659 Bytes
Contents
module RailsLiveDashboard module Types class Content < ActiveRecord::Type::Value CONTENT_STRUCT = Struct.new(*self.PAYLOAD) def type :jsonb end def cast(value) sanitized = sanitize_input(value) CONTENT_STRUCT.new(**sanitized) end def deserialize(value) decoded = ActiveSupport::JSON.decode(value) sanitized = sanitize_input(decoded) CONTENT_STRUCT.new(**sanitized) end def serialize(value) ActiveSupport::JSON.encode(value) end private def sanitize_input(input) input.slice(*self.PAYLOAD) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems