Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::TypeMap

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/connection_adapters/postgresql/oid.rb

Instance Method Summary collapse

Constructor Details

#initializeTypeMap

Returns a new instance of TypeMap.



279
280
281
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 279

def initialize
  @mapping = {}
end

Instance Method Details

#[](oid) ⇒ Object



287
288
289
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 287

def [](oid)
  @mapping[oid]
end

#[]=(oid, type) ⇒ Object



283
284
285
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 283

def []=(oid, type)
  @mapping[oid] = type
end

#clearObject



291
292
293
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 291

def clear
  @mapping.clear
end

#fetch(ftype, fmod) ⇒ Object



299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 299

def fetch(ftype, fmod)
  # The type for the numeric depends on the width of the field,
  # so we'll do something special here.
  #
  # When dealing with decimal columns:
  #
  # places after decimal  = fmod - 4 & 0xffff
  # places before decimal = (fmod - 4) >> 16 & 0xffff
  if ftype == 1700 && (fmod - 4 & 0xffff).zero?
    ftype = 23
  end

  @mapping.fetch(ftype) { |oid| yield oid, fmod }
end

#key?(oid) ⇒ Boolean

Returns:



295
296
297
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 295

def key?(oid)
  @mapping.key? oid
end