-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pretend to be instance_of?(source.class) #417
Conversation
This is also super failing on Travis. |
Yeah, this is going to fail hard at the moment due to the minitest-rails update, but it'll be fine after #416. |
Re-building! |
Travis seems to be doing something slightly odd with it. I'll rebase it and see what happens! |
Hmmm, we had another round of that internal server error on an earlier build (before I fixed a goof that was giving a spurious warning, and removed the pending spec). Since it's almost certainly unrelated to this particular PR, I think this can still go in, but I will investigate further. |
Pretend to be instance_of?(source.class)
Seems legit. |
Decorators shouldn't pretend to be instances of the underlying model classes for the following reasons: 1. It's terribly wrong to pretend being a class without implementing it's interface. It can break third party code. 2. Hacking Ruby core methods can lead to unexpected and hard to understand behavior. It should be avoided without a strong reason behind. 3. I'd prefer compatibility patches to be narrow-scoped and live in there own modules. Resolves drapergem#859. Reverts drapergem#72, drapergem#110, drapergem#417, drapergem#497.
Decorators shouldn't pretend to be instances of the underlying model classes for the following reasons: 1. It's terribly wrong to pretend being a class without implementing it's interface. It can break third party code. 2. Hacking Ruby core methods can lead to unexpected and hard to understand behavior. It should be avoided without a strong reason behind. 3. I'd prefer compatibility patches to be narrow-scoped and live in there own modules. Resolves #859. Reverts #72, #110, #417, #497.
We pretend to be a
kind_of?
the source class, so I think it also makes sense to pretend to be aninstance_of?
the same.I only had to tweak the
handle_multiple_decoration
stuff, otherwise no changes were necessary (although the specs will fail on Travis until #416 goes in).As a nice bonus, this would make this spec pass on Rails 3.0 - it doesn't at the moment because in 3.0
ActiveRecord::Base#==
doesn't callsuper
, so it doesn't hitDecoratable#==
:Compared to, on 3.2 (and similarly on 3.1),