diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-05-20 08:07:02 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-05-20 13:22:39 -0700 |
commit | ac4c1c3b0adabecdb1217594fed16db32b27ee9e (patch) | |
tree | 579e3bcc85ca624c70ed48bff157b76dec6ea3c8 /activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb | |
parent | f3407d1392ed55aa4ff0a7d50ea6722f251c86ac (diff) | |
download | rails-ac4c1c3b0adabecdb1217594fed16db32b27ee9e.tar.gz rails-ac4c1c3b0adabecdb1217594fed16db32b27ee9e.tar.bz2 rails-ac4c1c3b0adabecdb1217594fed16db32b27ee9e.zip |
Use the generic type map object for mysql field lookups
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb b/activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb new file mode 100644 index 0000000000..828ada00a7 --- /dev/null +++ b/activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb @@ -0,0 +1,15 @@ +module ActiveRecord + module ConnectionAdapters + module Type + class HashLookupTypeMap < TypeMap # :nodoc: + def lookup(type) + @mapping.fetch(type, proc { default_value }).call(type) + end + + def alias_type(type, alias_type) + register_type(type) { lookup(alias_type) } + end + end + end + end +end |