rails/rails — pull request #9455 by Jiebour (2013-02-27 02:35:49+00:00)
Title: Use polymorphism instead of case/when. Not use symbols to initialize Range any more.

(1)Not use symbols to initialize Range any more.
now its like this:
register_type 'daterange', OID::Range.new(OID::Date.new, OID::Date.new)
register_type 'numrange', OID::Range.new(OID::Decimal.new, OID::Decimal.new)
register_type 'tsrange', OID::Range.new(OID::Time.new, OID::Time.new)
register_type 'int4range', OID::Range.new(OID::Integer.new, OID::Integer.new)

(2)delete the method infinity.Because its useless. -1 can replace it!

(3)modify the initialize function, now its like this:
def initialize(left_type, right_type)
@left_type = left_type
@right_type = right_type
end

(4)change the function type_cast to type_cast_of_from and type_cast_of_to in class Date, Time, Decimal and Integer to get "from" and "to".

(5)use polymorphism instead of case/when.
now its like this:
from = @left_type.type_cast_of_from extracted
to = @right_type.type_cast_of_to extracted