Skip to content
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

Refactoring: extract delegating logic. #147

Merged
merged 1 commit into from
Jul 20, 2015

Conversation

marshall-lee
Copy link
Member

This one solves many problems at once:

  • Fixes :safe option #140. For this one I changed specs a bit. It's breaking but I think it's worth it.
  • Fixes Fix safe private method calls #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.

@marshall-lee marshall-lee force-pushed the delegators branch 4 times, most recently from 1fb3628 to 971d7c4 Compare July 20, 2015 16:29
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.
@dblock
Copy link
Member

dblock commented Jul 20, 2015

I like this, merging as is.

dblock added a commit that referenced this pull request Jul 20, 2015
Refactoring: extract delegating logic.
@dblock dblock merged commit a4aa641 into ruby-grape:master Jul 20, 2015
marshall-lee added a commit to marshall-lee/grape-entity that referenced this pull request Aug 3, 2015
This one fixes a regression introduced in ruby-grape#147: entity instance methods
were exposed with `NoMethodError`.
Fixes ruby-grape#163. Additional specs are added.
marshall-lee added a commit to marshall-lee/grape-entity that referenced this pull request Aug 3, 2015
This one fixes a regression introduced in ruby-grape#147: entity instance methods
were exposed with `NoMethodError`.
Fixes ruby-grape#163. Additional specs are added.
marshall-lee added a commit to marshall-lee/grape-entity that referenced this pull request Aug 3, 2015
This one fixes a regression introduced in ruby-grape#147: entity instance methods
were exposed with `NoMethodError`.
Fixes ruby-grape#163. Additional specs are added.
marshall-lee added a commit to marshall-lee/grape-entity that referenced this pull request Aug 3, 2015
This one fixes a regression introduced in ruby-grape#147: entity instance methods
were exposed with `NoMethodError`.
Fixes ruby-grape#163. Additional specs are added.
marshall-lee added a commit to marshall-lee/grape-entity that referenced this pull request Aug 10, 2015
This one fixes a regression introduced in ruby-grape#147: entity instance methods
were exposed with `NoMethodError`.
Fixes ruby-grape#163. Additional specs are added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants