25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/paquito/types/active_record_packer.rb', line 25
def self.dump(value)
coded = ActiveRecordCoder.dump(value)
FACTORY.dump(coded)
rescue NoMethodError, PackError => e
raise unless PackError === e || e.name == :to_msgpack
class_name = value.class.name
receiver_name = e.receiver.class.name
error_attrs = coded[1][1].select { |_, attr_value| VALID_CLASSES.exclude?(attr_value.class) }
Rails.logger.warn(<<~LOG.squish)
[MessagePackCodecTypes]
Failed to encode record with ActiveRecordCoder
class=#{class_name}
error_class=#{receiver_name}
error_attrs=#{error_attrs.keys.join(", ")}
LOG
raise PackError.new("failed to pack ActiveRecord object", e.receiver)
end
|