2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
# Overrides `as_json` and `to_json` to raise an exception when called in order
|
|
|
|
# to prevent accidentally exposing attributes
|
|
|
|
#
|
2019-02-15 15:39:39 +05:30
|
|
|
# Not that would ever happen... but just in case.
|
2018-03-17 18:26:18 +05:30
|
|
|
module BlocksJsonSerialization
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
JsonSerializationError = Class.new(StandardError)
|
|
|
|
|
|
|
|
def to_json(*)
|
|
|
|
raise JsonSerializationError,
|
|
|
|
"JSON serialization has been disabled on #{self.class.name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
alias_method :as_json, :to_json
|
|
|
|
end
|