Module: Steep::Equatable

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/steep/equatable.rb', line 3

def ==(other)
  if other.class == self.class
    instance_variables.all? do |name|
      other.instance_variable_get(name) == instance_variable_get(name)
    end
  else
    false
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/steep/equatable.rb', line 13

def eql?(other)
  self == other
end

#hashObject



17
18
19
20
21
# File 'lib/steep/equatable.rb', line 17

def hash
  instance_variables.inject(self.class.hash) do |hash, name|
    hash ^ instance_variable_get(name).hash
  end
end