edge badge
Methods
E
I
N
S
T
Attributes
[R] subtype
Class Public methods
new(subtype)
# File activerecord/lib/active_record/connection_adapters/postgresql/oid.rb, line 144
def initialize(subtype)
  @subtype = subtype
end
Instance Public methods
extract_bounds(value)
# File activerecord/lib/active_record/connection_adapters/postgresql/oid.rb, line 148
def extract_bounds(value)
  from, to = value[1..-2].split(',')
  {
    from:          (value[1] == ',' || from == '-infinity') ? @subtype.infinity(negative: true) : from,
    to:            (value[-2] == ',' || to == 'infinity') ? @subtype.infinity : to,
    exclude_start: (value[0] == '('),
    exclude_end:   (value[-1] == ')')
  }
end
infinity?(value)
# File activerecord/lib/active_record/connection_adapters/postgresql/oid.rb, line 158
def infinity?(value)
  value.respond_to?(:infinite?) && value.infinite?
end
simplified_type(sql_type)
# File activerecord/lib/active_record/connection_adapters/postgresql/oid.rb, line 142
def simplified_type(sql_type); sql_type.to_sym end
type_cast(value)
# File activerecord/lib/active_record/connection_adapters/postgresql/oid.rb, line 166
          def type_cast(value)
            return if value.nil? || value == 'empty'
            return value if value.is_a?(::Range)

            extracted = extract_bounds(value)
            from = type_cast_single extracted[:from]
            to = type_cast_single extracted[:to]

            if !infinity?(from) && extracted[:exclude_start]
              if from.respond_to?(:succ)
                from = from.succ
                ActiveSupport::Deprecation.warn <<-MESSAGE
Excluding the beginning of a Range is only partialy supported through `#succ`.
This is not reliable and will be removed in the future.
                MESSAGE
              else
                raise ArgumentError, "The Ruby Range object does not support excluding the beginning of a Range. (unsupported value: '#{value}')"
              end
            end
            ::Range.new(from, to, extracted[:exclude_end])
          end
type_cast_single(value)
# File activerecord/lib/active_record/connection_adapters/postgresql/oid.rb, line 162
def type_cast_single(value)
  infinity?(value) ? value : @subtype.type_cast(value)
end