lib/dry/equalizer.rb in dry-equalizer-0.2.0 vs lib/dry/equalizer.rb in dry-equalizer-0.2.1
- old
+ new
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
module Dry
# Build an equalizer module for the inclusion in other class
#
# @api public
def self.Equalizer(*keys)
@@ -19,11 +17,11 @@
#
# @return [undefined]
#
# @api private
def initialize(*keys)
- @keys = keys
+ @keys = keys.uniq
define_methods
freeze
end
private
@@ -86,12 +84,12 @@
# @api private
def define_inspect_method
keys = @keys
define_method(:inspect) do | |
klass = self.class
- name = klass.name || klass.inspect
- "#<#{name}#{keys.map { |key| " #{key}=#{__send__(key).inspect}" }.join}>"
+ name = klass.name || klass.inspect
+ "#<#{name}#{keys.map { |key| " #{key}=#{__send__(key).inspect}" }.join}>"
end
end
# The comparison methods
module Methods
@@ -120,10 +118,10 @@
#
# @return [Boolean]
#
# @api public
def ==(other)
- other.kind_of?(self.class) && cmp?(__method__, other)
+ other.is_a?(self.class) && cmp?(__method__, other)
end
end # module Methods
end # class Equalizer
end