anonymous / gist:614ccbbe263cd1196203 secret
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:614ccbbe263cd1196203
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
require 'active_support/concern'
require 'active_support/core_ext/object/acts_like'
 
module InfiniteComparable
extend ActiveSupport::Concern
 
included do
class_exec do
alias_method_chain :<=>, :other
 
end
end
 
define_method :'<=>_with_other' do |other|
return self.send(:'<=>_without_other', other) if other.class == self.class
 
conversion = :"to_#{self.class.name.downcase}"
if other.respond_to?(:infinite?) && other.infinite?
-other.infinite?
elsif other.respond_to?(conversion)
self.send(:'<=>_without_other', other.send(conversion))
else
self.send(:'<=>_without_other', other)
end
end
 
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.