-
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
Delegate CollectionDecorator#kind_of? to the underlying decorated collection #497
Delegate CollectionDecorator#kind_of? to the underlying decorated collection #497
Conversation
Thanks for picking this up! However, I think maybe what you intended to do was something along the lines of: alias_method :orig_kind_of, :kind_of
def kind_of?(klass)
decorated_collection.kind_of?(klass) || orig_kind_of(klass)
end
alias :is_a? :kind_of? The line that you replaced in 63721db is necessary as long as we want to maintain the |
The JRuby failures are Travis' fault, so I'm not worrying about that. It's fixed in edge bundler/rubygems, they should be releasing/updating soonish. I think that this is fine, both of them work, but this way, we don't have the extra method lying around. |
Delegate CollectionDecorator#kind_of? to the underlying decorated collection
@jtrim |
Yeah, I tend to prefer plain |
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.
Incorporates #488, using
alias_method
instead ofalias
for consistency. Thanks, @jtrim!