mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Avoid using extend in Decorator#==
This commit is contained in:
parent
43359e0efc
commit
205a0d43b4
2 changed files with 16 additions and 4 deletions
|
@ -5,9 +5,21 @@ module Draper
|
|||
#
|
||||
# @return [Boolean]
|
||||
def ==(other)
|
||||
super ||
|
||||
other.respond_to?(:decorated?) && other.decorated? &&
|
||||
other.respond_to?(:source) && self == other.source
|
||||
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
|
||||
|
|
|
@ -163,7 +163,7 @@ module Draper
|
|||
#
|
||||
# @return [Boolean]
|
||||
def ==(other)
|
||||
source.extend(Draper::Decoratable::Equality) == other
|
||||
Draper::Decoratable::Equality.test(source, other)
|
||||
end
|
||||
|
||||
# Checks if `self.kind_of?(klass)` or `source.kind_of?(klass)`
|
||||
|
|
Loading…
Add table
Reference in a new issue