1# frozen_string_literal: true 2 3# Overrides `as_json` and `to_json` to raise an exception when called in order 4# to prevent accidentally exposing attributes 5# 6# Not that would ever happen... but just in case. 7module BlocksJsonSerialization 8 extend ActiveSupport::Concern 9 10 JsonSerializationError = Class.new(StandardError) 11 12 def to_json(*) 13 raise JsonSerializationError, 14 "JSON serialization has been disabled on #{self.class.name}" 15 end 16 17 alias_method :as_json, :to_json 18end 19