module ActiveModelSerializers::Model::DeriveAttributesFromNamesAndFixAccessors
def attributes
+attributes+ are returned frozen to prevent any expectations that mutation affects
The fields in +attribute_names+ determines the returned hash.
Override the +attributes+ method so that the hash is derived from +attribute_names+.
def attributes self.class.attribute_names.each_with_object({}) do |attribute_name, result| result[attribute_name] = public_send(attribute_name).freeze end.with_indifferent_access.freeze end