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
|
|
|
|
#
|
2018-11-19 09:08:23 -05:00
|
|
|
# Not that would ever happen... but just in case.
|
2017-09-18 23:18:51 -04:00
|
|
|
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
|