Sha256: 55bcc3de1fe5df3790855fef5c477e4bb99e704335d94362c2ff8f0842e46778

Contents?: true

Size: 671 Bytes

Versions: 3

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

require_relative 'acts_as_delta'

module HashDeepDiff
  module Delta
    # Representation of the pure right diff
    # i.e element that are missing in the hash on the right of the comparison
    # for example right diff of {} and { a: a } is { a: a }
    class Right
      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/right.rb
hash_deep_diff-0.3.1 lib/hash_deep_diff/delta/right.rb
hash_deep_diff-0.3.0 lib/hash_deep_diff/delta/right.rb