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