Sha256: 0f3f14d94254734be0bc1e878c2e979f391299a9f0b92c972a240545e1b097ac
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true require_relative 'acts_as_delta' module HashDeepDiff module Delta # Representation of the pure left diff # i.e element that are missing in the hash on the right of the comparison # for example left diff of { a: a } and {} is { a: a } class Inner include Delta::ActsAsDelta def to_str if @delta.values.first.respond_to?(:to_hash) if @delta.values.first.keys == %i[left right] if @delta.values.first[:left].respond_to?(:to_hash) && @delta.values.first[:right].respond_to?(:to_hash) HashDeepDiff::Comparison.new( @delta.values.first[:left], @delta.values.first[:right], path ).report else lines = <<~Q -left#{diff_prefix} = #{@delta.values.first[:left]} +right#{diff_prefix} = #{@delta.values.first[:right]} Q lines.strip end else @delta.values.first.keys.map do |key| self.class.new(path: path + [key], value: @delta.values.first[key]) end.join("\n").strip end else lines = <<~Q -left#{diff_prefix} = #{@delta.values.first[:left]} +right#{diff_prefix} = #{@delta.values.first[:right]} Q lines.strip end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hash_deep_diff-0.3.1 | lib/hash_deep_diff/delta/inner.rb |
hash_deep_diff-0.3.0 | lib/hash_deep_diff/delta/inner.rb |