Sha256: 9279567220e80eae19617e46ea71ed013dacb139fc209d36581d25906d554ba5

Contents?: true

Size: 461 Bytes

Versions: 46

Compression:

Stored size: 461 Bytes

Contents

module Steep
  module Equatable
    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

    def eql?(other)
      self == other
    end

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

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
steep-1.3.0 lib/steep/equatable.rb
steep-1.3.0.pre.2 lib/steep/equatable.rb
steep-1.3.0.pre.1 lib/steep/equatable.rb
steep-1.2.1 lib/steep/equatable.rb
steep-1.2.0 lib/steep/equatable.rb
steep-1.2.0.pre.1 lib/steep/equatable.rb