1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

added Casted#hash

This commit is contained in:
Bert Bruynooghe 2016-02-17 22:30:10 +01:00
parent 1483482782
commit df9dd77ee5
2 changed files with 20 additions and 0 deletions

View file

@ -10,6 +10,10 @@ module Arel
def nil?; @val.nil?; end
def hash
[@class, @val, @attribute].hash
end
def eql? other
self.class == other.class &&
self.val == other.val &&

16
test/nodes/test_casted.rb Normal file
View file

@ -0,0 +1,16 @@
require 'helper'
module Arel
module Nodes
describe Casted do
describe '#hash' do
it 'is equal when eql? returns true' do
one = Casted.new 1, 2
also_one = Casted.new 1, 2
assert_equal one.hash, also_one.hash
end
end
end
end
end