Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::TypeMap
- Defined in:
- activerecord/lib/active_record/connection_adapters/postgresql/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.
251 252 253 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 251 def initialize @mapping = {} end |
Instance Method Details
#[](oid) ⇒ Object
259 260 261 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 259 def [](oid) @mapping[oid] end |
#[]=(oid, type) ⇒ Object
255 256 257 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 255 def []=(oid, type) @mapping[oid] = type end |
#clear ⇒ Object
263 264 265 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 263 def clear @mapping.clear end |
#fetch(ftype, fmod) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 271 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
267 268 269 |
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 267 def key?(oid) @mapping.key? oid end |