From ecf4ad7cca206e2cf99ca16e57e17648e726877a Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 22 May 2014 09:12:23 -0700 Subject: Allow additional arguments to be used during type map lookups Determining things like precision and scale in postgresql will require the given blocks to take additional arguments besides the OID. - Adds the ability to handle additional arguments to `TypeMap` - Passes the column type to blocks when looking up PG types --- .../connection_adapters/type/hash_lookup_type_map.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/type/hash_lookup_type_map.rb') 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 8503d3ea1b..bb1abc77ff 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 @@ -4,16 +4,16 @@ module ActiveRecord class HashLookupTypeMap < TypeMap # :nodoc: delegate :key?, to: :@mapping - def lookup(type) - @mapping.fetch(type, proc { default_value }).call(type) + def lookup(type, *args) + @mapping.fetch(type, proc { default_value }).call(type, *args) end - def fetch(type, &block) - @mapping.fetch(type, block).call(type) + def fetch(type, *args, &block) + @mapping.fetch(type, block).call(type, *args) end def alias_type(type, alias_type) - register_type(type) { lookup(alias_type) } + register_type(type) { |_, *args| lookup(alias_type, *args) } end end end -- cgit v1.2.3