Skip to content

Commit

Permalink
Deal with rails 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
khiav reoy committed Jul 30, 2023
1 parent e45f999 commit ec2ff0d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/rails_compatibility/cast_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def cast_values(klass, result)
next attributes
end
end
else
elsif GTE_RAILS_4_0
def cast_values(klass, result)
attribute_types = self.attribute_types(klass)

Expand All @@ -27,6 +27,17 @@ def cast_values(klass, result)
attributes[key] = deserialize(result.send(:column_type, key, attribute_types), attribute)
end

next attributes
end
end
else
def cast_values(klass, result)
result.map! do |attributes| # This map! behaves different to array#map!
initialized_attributes = klass.initialize_attributes(attributes)
attributes.each do |key, _attribute|
attributes[key] = klass.type_cast_attribute(key, initialized_attributes)
end

next attributes
end
end
Expand Down

0 comments on commit ec2ff0d

Please sign in to comment.