Sha256: 7e9bcb740a698a2ae43b7cdc40b30e4ab5bf142c274022fd8be242ca2077b6b9

Contents?: true

Size: 382 Bytes

Versions: 18

Compression:

Stored size: 382 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

18 entries across 17 versions & 2 rubygems

Version Path
paper_trail-7.1.0 spec/support/custom_json_serializer.rb
paper_trail-7.0.3 spec/support/custom_json_serializer.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paper_trail-7.0.2/test/custom_json_serializer.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paper_trail-5.2.3/test/custom_json_serializer.rb
paper_trail-7.0.2 test/custom_json_serializer.rb
paper_trail-7.0.1 test/custom_json_serializer.rb
paper_trail-7.0.0 test/custom_json_serializer.rb
paper_trail-6.0.2 test/custom_json_serializer.rb
paper_trail-6.0.1 test/custom_json_serializer.rb
paper_trail-6.0.0 test/custom_json_serializer.rb
paper_trail-5.2.3 test/custom_json_serializer.rb
paper_trail-5.2.2 test/custom_json_serializer.rb
paper_trail-5.2.1 test/custom_json_serializer.rb
paper_trail-5.2.0 test/custom_json_serializer.rb
paper_trail-5.1.1 test/custom_json_serializer.rb
paper_trail-5.1.0 test/custom_json_serializer.rb
paper_trail-5.0.1 test/custom_json_serializer.rb
paper_trail-5.0.0 test/custom_json_serializer.rb