Sha256: aa001ca29844823f43c6abe2498f5ec61386af8e87fbb8111c858b825aff2b19
Contents?: true
Size: 661 Bytes
Versions: 1
Compression:
Stored size: 661 Bytes
Contents
# typed: strict # frozen_string_literal: true module T class Struct module ActsAsComparable extend T::Sig include ::Comparable EQUAL = 0 NOT_COMPARABLE = nil sig { params(other: Object).returns(T.nilable(Integer)) } def <=>(other) return NOT_COMPARABLE if other.class != T.unsafe(self).class T.unsafe(self).class.decorator.props.keys.each do |attribute_key| compare_result = T.unsafe(self).send(attribute_key) <=> other.send(attribute_key) return T.cast(compare_result, T.nilable(Integer)) if compare_result != EQUAL end return EQUAL end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sorbet-struct-comparable-1.1.0 | lib/t/struct/acts_as_comparable.rb |