solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 229 forks source link

Improve value_object's #hash uniformity #233

Closed codesnik closed 10 years ago

codesnik commented 10 years ago

Array#hash is designed to be uniform, unlike reduce(:^).hash

class Point
  include Virtus.value_object
  values do
     attribute :x, Integer
     attribute :y, Integer
  end
end

Point.new(x: 1, y: 1).hash == Point.new.hash # was true
Point.new(x: 1).hash == Point.new(y: 1).hash # was true
coveralls commented 10 years ago

Coverage Status

Coverage decreased (-0.02%) when pulling 28c718e102062ce3ebb280fc81833f31776a028d on codesnik:fixing_hash into 6e7f6df52e5ccf2147146a5dabccec128da0ac6a on solnic:master.

dkubb commented 10 years ago

I just applied this fix to similar code within equalizer, eg: https://github.com/dkubb/equalizer/blob/master/lib/equalizer.rb#L66-L71

solnic commented 10 years ago

Thanks, I'm gonna merge it in even though there's no test covering this as it's a deprecated module anyway and I'll remove it in 2.0.0. Once new equalizer is released I will bump its dependency here and release new version of virtus.