Sha256: 7375a580a0875b4145dcc52711848798f354f9e5761a9b0fef2c97fc8d360e9b

Contents?: true

Size: 378 Bytes

Versions: 19

Compression:

Stored size: 378 Bytes

Contents

# This custom serializer excludes nil values
module CustomJsonSerializer
  extend PaperTrail::Serializers::JSON

  def self.load(string)
    parsed_value = super(string)
    parsed_value.is_a?(Hash) ? parsed_value.reject { |k,v| k.blank? || v.blank? } : parsed_value
  end

  def self.dump(object)
    object.is_a?(Hash) ? super(object.reject { |k,v| v.nil? }) : super
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
paper_trail-4.2.0 test/custom_json_serializer.rb
paper_trail-4.1.0 test/custom_json_serializer.rb
paper_trail-4.0.2 test/custom_json_serializer.rb
paper_trail-4.0.1 test/custom_json_serializer.rb
paper_trail-3.0.9 test/custom_json_serializer.rb
paper_trail-4.0.0 test/custom_json_serializer.rb
paper_trail-4.0.0.rc2 test/custom_json_serializer.rb
paper_trail-4.0.0.rc1 test/custom_json_serializer.rb
paper_trail-3.0.8 test/custom_json_serializer.rb
paper_trail-3.0.7 test/custom_json_serializer.rb
paper_trail-4.0.0.beta2 test/custom_json_serializer.rb
paper_trail-4.0.0.beta1 test/custom_json_serializer.rb
paper_trail-3.0.6 test/custom_json_serializer.rb
paper_trail-3.0.5 test/custom_json_serializer.rb
paper_trail-3.0.2 test/custom_json_serializer.rb
paper_trail-3.0.1 test/custom_json_serializer.rb
paper_trail-3.0.0 test/custom_json_serializer.rb
paper_trail-3.0.0.rc2 test/custom_json_serializer.rb
paper_trail-3.0.0.rc1 test/custom_json_serializer.rb