Skip to content

Commit

Permalink
Fix use of coerce method
Browse files Browse the repository at this point in the history
The gem's use of the #coerce method does not comport with the API as
established by Ruby itself (e.g. http://ruby-doc.org/core-1.9.3/Numeric.html#method-i-coerce).

This tweaks the usage of the return value to conform to the standard
API.
  • Loading branch information
craiglittle committed Feb 21, 2015
1 parent a6c5227 commit 0f13677
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/equalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def eql?(other)
#
# @api public
def ==(other)
other = coerce(other) if respond_to?(:coerce, true)
other = coerce(other).first if respond_to?(:coerce, true)
other.is_a?(self.class) && cmp?(__method__, other)
end
end # module Methods
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/equalizer/methods/equality_operator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def cmp?(comparator, other)
# declare a private #coerce method
described_class.class_eval do
def coerce(other)
self.class.new(!!other)
[self.class.new(!!other), self]
end
private :coerce
end
Expand Down

0 comments on commit 0f13677

Please sign in to comment.