aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-20 18:05:35 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-20 18:05:35 -0300
commit90a82cbfb26a24f801864a7fd2664553876b51f3 (patch)
tree3d2d876e7a723f8f4ac9cb5e340e6fe1f5aa50b2 /activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb
parentc4640ca8053c3d71ac0ff7c644fcbfa2ba54e275 (diff)
parent9f61f31c2cbf8c1d7b6ce33f28c67f900774fd58 (diff)
downloadrails-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.rb6
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