Files

Class/Module Index [+]

Quicksearch

ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Range

Attributes

subtype[R]

Public Class Methods

new(subtype) click to toggle source
# File lib/arjdbc/postgresql/base/oid.rb, line 157
def initialize(subtype)
  @subtype = subtype
end

Public Instance Methods

extract_bounds(value) click to toggle source
# File lib/arjdbc/postgresql/base/oid.rb, line 161
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) click to toggle source
# File lib/arjdbc/postgresql/base/oid.rb, line 171
def infinity?(value)
  value.respond_to?(:infinite?) && value.infinite?
end
simplified_type(sql_type) click to toggle source
# File lib/arjdbc/postgresql/base/oid.rb, line 155
def simplified_type(sql_type); sql_type.to_sym end
type_cast(value) click to toggle source
# File lib/arjdbc/postgresql/base/oid.rb, line 179
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 Excluding the beginning of a Range is only partialy supported through `#succ`.This is not reliable and will be removed in the future.
    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) click to toggle source
# File lib/arjdbc/postgresql/base/oid.rb, line 175
def type_cast_single(value)
  infinity?(value) ? value : @subtype.type_cast(value)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.