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

PaperTrail.request { } should return the value of the block to aid in passive wrapping #1074

Closed

Conversation

krainboltgreene
Copy link
Contributor

So I just spent the last 3 hours debugging because (ultimately) I had overwritten a method that some library depended on and I assumed that the below would be passively wrapping:

def valid_for_authentication?(*)
  PaperTrail.request(whodunnit: "The Machine") do
    super
  end
end

Turns out it doesn't, because it's forced to return nil.

Copy link
Member

@jaredbeck jaredbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Kurtis. Looks good. Please:

  1. Document the return type in the method documentation
  2. Add a test
  3. Add an entry to the changelog under Unreleased -> Added

@krainboltgreene
Copy link
Contributor Author

@jaredbeck The whole point of this PR is that the return type could be anything.

CHANGELOG.md Outdated
ApplicationError
end
# => ApplicationError has been raised!
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, please put this under "Added". I don't see it as a breaking change.

Also, please omit the code example. The single sentence description is sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're changing the return type of a public method from always nil to sometimes nil, are you sure that's not a breaking change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're changing the return type of a public method from always nil to sometimes nil, are you sure that's not a breaking change?

Yes, you're right (both correct and righteous) to question this 😁 I don't consider it a breaking change, because I don't think anyone is depending on the fact that it is returning nil. What do you think? Do you think people will be depending on the nil?

@jaredbeck
Copy link
Member

Document the return type in the method documentation

@jaredbeck The whole point of this PR is that the return type could be anything.

To clarify, I'd like the method documentation to say something like "If a block is given, returns value from block"

@krainboltgreene
Copy link
Contributor Author

Roger.

Copy link
Member

@jaredbeck jaredbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs requested change to method documentation

@@ -7,7 +7,7 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).

### Breaking Changes

- None
- `PaperTrail.request do ... end` now returns whatever value is returned from the given block.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still listed under "Breaking Changes" and I still think it should be under "Added" for the reasons I have already given. I'm open to arguments either way, but I haven't heard any convincing arguments for it being a breaking change yet.

@jaredbeck
Copy link
Member

Closing via #1077, preserving your authorship. Thanks Kurtis.

@jaredbeck jaredbeck closed this Apr 23, 2018
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