Skip to content

Prefer public_send to collaborating objects#308

Merged
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
gschorkopf:access-levels
Jul 14, 2015
Merged

Prefer public_send to collaborating objects#308
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
gschorkopf:access-levels

Conversation

@gschorkopf
Copy link
Copy Markdown
Contributor

Background

While upgrading to a recent release, we noticed due to failing tests that the resource object was accessing a private interface on our model. We traced this back to the send calls. The fix for our code was to specify a :relation_name option so that the appropriate interface is accessed. It would be nice for the relation object to complain earlier about the missing interface which was working by chance only because we had a private method matching the message it sent.

Note

We've chosen to keep some of the send calls sent to the object itself. We did note that the jsonapi-resources test suite still passed even when changing these calls to public_send. However, we didn't feel confident enough in our knowledge of these calls to make the change here.

* This prevents inadvertent access level violations
lgebhardt added a commit that referenced this pull request Jul 14, 2015
Prefer public_send to collaborating objects
@lgebhardt lgebhardt merged commit 9f58ec5 into JSONAPI-Resources:master Jul 14, 2015
@lgebhardt
Copy link
Copy Markdown
Contributor

Thanks! I think using public_send over send is a better default now that we've eliminated ruby 1.8.7 from support.

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.

2 participants