Sha256: 0e67c7b1daf3a1d64a083d03395290c4abf6b6482681fb27ea422c7a77308365

Contents?: true

Size: 668 Bytes

Versions: 3

Compression:

Stored size: 668 Bytes

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 Left
      include Delta::ActsAsDelta

      def to_str
        if @delta.values.first.respond_to?(:to_hash)
          @delta.values.first.keys.map do |key|
            self.class.new(path: path + [key], value: @delta.values.first[key])
          end.join("\n").strip
        else
          "+left#{diff_prefix} = #{@delta.values.first}"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hash_deep_diff-0.3.2 lib/hash_deep_diff/delta/left.rb
hash_deep_diff-0.3.1 lib/hash_deep_diff/delta/left.rb
hash_deep_diff-0.3.0 lib/hash_deep_diff/delta/left.rb