| In: |
lib/rq-3.0.0/sqlite.rb
|
| Parent: | Object |
The TypeTranslator is a singleton class that manages the routines that have been registered to convert particular types. The translator only manages conversions in queries (where data is coming out of the database), and not updates (where data is going into the database).
Registers the given block to be used when a value of the given type needs to be translated from a string.
# File lib/rq-3.0.0/sqlite.rb, line 237
237: def self.add_translator( type, &block )
238: @@translators[ type_name( type ) ] = block
239: end
Looks up the translator for the given type, and asks it to convert the given value.
# File lib/rq-3.0.0/sqlite.rb, line 243
243: def self.translate( type, value )
244: unless value.nil?
245: @@translators[ type_name( type ) ].call( type, value )
246: end
247: end