2018-08-03 13:22:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-18 23:18:51 -04:00
|
|
|
# Overrides `as_json` and `to_json` to raise an exception when called in order
|
|
|
|
# to prevent accidentally exposing attributes
|
|
|
|
#
|
|
|
|
# Not that that would ever happen... but just in case.
|
|
|
|
module BlocksJsonSerialization
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2017-12-01 12:33:02 -05:00
|
|
|
JsonSerializationError = Class.new(StandardError)
|
|
|
|
|
|
|
|
def to_json(*)
|
|
|
|
raise JsonSerializationError,
|
2017-09-18 23:18:51 -04:00
|
|
|
"JSON serialization has been disabled on #{self.class.name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
alias_method :as_json, :to_json
|
|
|
|
end
|