Sha256: 6700cb3d925c003fed9e5972f9bcb8a74c793b0b11e5da4fed9c0659f2ff4ee8

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

module Draper
  module Decoratable
    module Equality
      # Compares self with a possibly-decorated object.
      #
      # @return [Boolean]
      def ==(other)
        super || Equality.test_for_decorator(self, other)
      end

      # Compares an object to a possibly-decorated object.
      #
      # @return [Boolean]
      def self.test(object, other)
        return object == other if object.is_a?(Decoratable)
        object == other || test_for_decorator(object, other)
      end

      # @private
      def self.test_for_decorator(object, other)
        other.respond_to?(:decorated?) && other.decorated? &&
        other.respond_to?(:source) && test(object, other.source)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
draper-1.2.0 lib/draper/decoratable/equality.rb