diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-20 18:05:35 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-20 18:05:35 -0300 |
commit | 90a82cbfb26a24f801864a7fd2664553876b51f3 (patch) | |
tree | 3d2d876e7a723f8f4ac9cb5e340e6fe1f5aa50b2 /activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb | |
parent | c4640ca8053c3d71ac0ff7c644fcbfa2ba54e275 (diff) | |
parent | 9f61f31c2cbf8c1d7b6ce33f28c67f900774fd58 (diff) | |
download | rails-90a82cbfb26a24f801864a7fd2664553876b51f3.tar.gz rails-90a82cbfb26a24f801864a7fd2664553876b51f3.tar.bz2 rails-90a82cbfb26a24f801864a7fd2664553876b51f3.zip |
Merge pull request #15206 from sgrif/sg-type-map-postgresql
Use the generic type map for PostgreSQL OID registrations
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 | 6 |
1 files changed, 6 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 index 828ada00a7..8503d3ea1b 100644 --- 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 @@ -2,10 +2,16 @@ module ActiveRecord module ConnectionAdapters module Type class HashLookupTypeMap < TypeMap # :nodoc: + delegate :key?, to: :@mapping + def lookup(type) @mapping.fetch(type, proc { default_value }).call(type) end + def fetch(type, &block) + @mapping.fetch(type, block).call(type) + end + def alias_type(type, alias_type) register_type(type) { lookup(alias_type) } end |