aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/legacy_thing.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2016-08-05 09:39:46 -0400
committerSean Griffin <sean@thoughtbot.com>2016-08-05 09:52:09 -0400
commitb63d532f1ed0770e00183894a9efd7450d8cde82 (patch)
tree2eb02d5093170d6371c5e2624b742cd7637570b8 /activerecord/test/models/legacy_thing.rb
parent320d40123ab0befe248373aab8ac2e2a3dec33cd (diff)
downloadrails-b63d532f1ed0770e00183894a9efd7450d8cde82.tar.gz
rails-b63d532f1ed0770e00183894a9efd7450d8cde82.tar.bz2
rails-b63d532f1ed0770e00183894a9efd7450d8cde82.zip
Don't assume all hashes are from multiparameter assignment in `composed_of`
So this bug is kinda funky. The code path is basically "if we weren't passed an instance of the class we compose to, and we have a converter, call that". Ignoring the hash case for a moment, everything after that was roughly intended to be the "else" clause, meaning that we are expected to have an instance of the class we compose to. Really, we should be blowing up in that case, as we can give a much better error message than what they user will likely get (e.g. `NameError: No method first for String` or something). Still, Ruby is duck typed, so if the object you're assigning responds to the same methods as the type you compose to, knock yourself out. The hash case was added in 36e9be8 to remove a bunch of special cased code from multiparameter assignment. I wrongly assumed that the only time we'd get a hash there is in that case. Multiparameter assignment will construct a very specific hash though, where the keys are integers, and we will have a set of keys covering `1..part.size` exactly. I'm pretty sure this could actually be passed around as an array, but that's a different story. Really I should convert this to something like `class MultiParameterAssignment < Hash; end`, which I might do soon. However for a change that I'm willing to backport to 4-2-stable, this is what I want to go with for the time being. Fixes #25978
Diffstat (limited to 'activerecord/test/models/legacy_thing.rb')
0 files changed, 0 insertions, 0 deletions