Skip to content

Commit 529421d

Browse files
committed
utilize the #klass method if its available
1 parent 8632f60 commit 529421d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def type_to_ids_mapping
1414
name = association.name
1515
default_hash = Hash.new { |hsh, key| hsh[key] = [] }
1616
values.each_with_object(default_hash) do |value, hash|
17-
klass = value.class
17+
klass = respond_to?(:klass) ? klass(value) : klass.class
1818
if association.active_record.respond_to?("#{name}_type_mapping")
1919
mapping = association.active_record.send("#{name}_type_mapping")
2020
key ||= mapping.key(klass.polymorphic_name) if klass.respond_to?(:polymorphic_name)

0 commit comments

Comments
 (0)