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:
parent
1483482782
commit
df9dd77ee5
2 changed files with 20 additions and 0 deletions
|
@ -10,6 +10,10 @@ module Arel
|
||||||
|
|
||||||
def nil?; @val.nil?; end
|
def nil?; @val.nil?; end
|
||||||
|
|
||||||
|
def hash
|
||||||
|
[@class, @val, @attribute].hash
|
||||||
|
end
|
||||||
|
|
||||||
def eql? other
|
def eql? other
|
||||||
self.class == other.class &&
|
self.class == other.class &&
|
||||||
self.val == other.val &&
|
self.val == other.val &&
|
||||||
|
|
16
test/nodes/test_casted.rb
Normal file
16
test/nodes/test_casted.rb
Normal 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
|
Loading…
Reference in a new issue