Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::TypeMap
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::TypeMap
- Defined in:
- lib/arjdbc/postgresql/base/oid.rb
Instance Method Summary collapse
- #[](oid) ⇒ Object
- #[]=(oid, type) ⇒ Object
- #clear ⇒ Object
- #fetch(ftype, fmod) ⇒ Object
-
#initialize ⇒ TypeMap
constructor
A new instance of TypeMap.
- #key?(oid) ⇒ Boolean
Constructor Details
#initialize ⇒ TypeMap
Returns a new instance of TypeMap.
298 299 300 |
# File 'lib/arjdbc/postgresql/base/oid.rb', line 298 def initialize @mapping = {} end |
Instance Method Details
#[](oid) ⇒ Object
306 307 308 |
# File 'lib/arjdbc/postgresql/base/oid.rb', line 306 def [](oid) @mapping[oid] end |
#[]=(oid, type) ⇒ Object
302 303 304 |
# File 'lib/arjdbc/postgresql/base/oid.rb', line 302 def []=(oid, type) @mapping[oid] = type end |
#clear ⇒ Object
310 311 312 |
# File 'lib/arjdbc/postgresql/base/oid.rb', line 310 def clear @mapping.clear end |
#fetch(ftype, fmod) ⇒ Object
318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/arjdbc/postgresql/base/oid.rb', line 318 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
314 315 316 |
# File 'lib/arjdbc/postgresql/base/oid.rb', line 314 def key?(oid) @mapping.key? oid end |