-
Notifications
You must be signed in to change notification settings - Fork 152
Fix safe private method calls #142
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
Fix safe private method calls #142
Conversation
It should be merged only if #140 is a false alarm. Otherwise it should be fixed differently |
997b784
to
75b28a7
Compare
75b28a7
to
603ac30
Compare
So the problem was private methods? I feel like an error that the method is private is almost better than exposing private methods automatically. What do you think? Either way this needs a CHANGELOG entry, please. |
It seems like exposing private methods was intented. It checks that object responds to attribute name using So this PR just makes safe and unsafe exposures behave identical because now only public methods can exposed when using As for me I don't like exposing private methods. If you think that only public methods should be exposed I could open a separate PR for this too. But it probably can be considered as a breaking change. Is it acceptable here? |
Ok I am with you on this one @marshall-lee. Lets call it a bug and add a line to CHANGELOG please (via |
This one solves many problems at once: - Fixes ruby-grape#140. For this one I changed specs a bit. It's breaking but I think it's worth it. - Fixes ruby-grape#142 differently because now `respond_to?(name, true)` stuff is incapsulated in `Delegator::PlainObject`. - Old `delegate_attribute` catched `NoMethodError` and re-raised it with custom message. It's incorrect because `NoMethodError` can occur deep inside in method call — this exception simply doesn't mean that attribute doesn't exist. - Solves the problem that object is checked to `is_a?(Hash)` and `respond_to?(:fetch, true)` multiple times. - Extracts delegating logic to separate delegator classes. - Removes constructing of `valid_exposures` at all — there's no need in this method now.
This one solves many problems at once: - Fixes ruby-grape#140. For this one I changed specs a bit. It's breaking but I think it's worth it. - Fixes ruby-grape#142 differently because now `respond_to?(name, true)` stuff is incapsulated in `Delegator::PlainObject`. - Old `delegate_attribute` catched `NoMethodError` and re-raised it with custom message. It's incorrect because `NoMethodError` can occur deep inside in method call — this exception simply doesn't mean that attribute doesn't exist. - Solves the problem that object is checked to `is_a?(Hash)` and `respond_to?(:fetch, true)` multiple times. - Extracts delegating logic to separate delegator classes. - Removes constructing of `valid_exposures` at all — there's no need in this method now.
This one solves many problems at once: - Fixes ruby-grape#140. For this one I changed specs a bit. It's breaking but I think it's worth it. - Fixes ruby-grape#142 differently because now `respond_to?(name, true)` stuff is incapsulated in `Delegator::PlainObject`. - Old `delegate_attribute` catched `NoMethodError` and re-raised it with custom message. It's incorrect because `NoMethodError` can occur deep inside in method call — this exception simply doesn't mean that attribute doesn't exist. - Solves the problem that object is checked to `is_a?(Hash)` and `respond_to?(:fetch, true)` multiple times. - Extracts delegating logic to separate delegator classes. - Removes constructing of `valid_exposures` at all — there's no need in this method now.
This one solves many problems at once: - Fixes ruby-grape#140. For this one I changed specs a bit. It's breaking but I think it's worth it. - Fixes ruby-grape#142 differently because now `respond_to?(name, true)` stuff is incapsulated in `Delegator::PlainObject`. - Old `delegate_attribute` catched `NoMethodError` and re-raised it with custom message. It's incorrect because `NoMethodError` can occur deep inside in method call — this exception simply doesn't mean that attribute doesn't exist. - Solves the problem that object is checked to `is_a?(Hash)` and `respond_to?(:fetch, true)` multiple times. - Extracts delegating logic to separate delegator classes. - Removes constructing of `valid_exposures` at all — there's no need in this method now.
This one solves many problems at once: - Fixes ruby-grape#140. For this one I changed specs a bit. It's breaking but I think it's worth it. - Fixes ruby-grape#142 differently because now `respond_to?(name, true)` stuff is incapsulated in `Delegator::PlainObject`. - Old `delegate_attribute` catched `NoMethodError` and re-raised it with custom message. It's incorrect because `NoMethodError` can occur deep inside in method call — this exception simply doesn't mean that attribute doesn't exist. - Solves the problem that object is checked to `is_a?(Hash)` and `respond_to?(:fetch, true)` multiple times. - Extracts delegating logic to separate delegator classes. - Removes constructing of `valid_exposures` at all — there's no need in this method now.
Related to #140