Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Deprecate calling #ab_seen with alternative instance #317

Conversation

urbanautomaton
Copy link
Contributor

As noted in #309, the #ab_seen adapter method currently takes an instance of Alternative, where all other adapter methods take an alternative id.

Since this has the potential to cause confusion, I thought it might be best to support both calling styles, logging a deprecation notice if the method is called with an Alternative instance, but still returning the correct response. We can then remove support for the old method signature after a respectful period of silence. :-)

(I've also silenced the deprecation warnings emitted by another test, hope that's okay.)

This test involves resetting Vanity, which sets a new logger at the default
level. This means that the legacy configuration method it supports prints a
deprecation to the test output.

We can capture the IO and assert the presence of a deprecation message
instead using minitest's #capture_io, setting a new logger within the captured
block.
@urbanautomaton urbanautomaton force-pushed the deprecate-ab-seen-with-alternative-instance branch from 7848975 to 1378e9a Compare November 23, 2016 11:36
Copy link
Collaborator

@phillbaker phillbaker left a comment

Choose a reason for hiding this comment

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

Looks good to me aside from the question about expanding the *args in the different adapters. Sorry about the slow review, the holiday in USA slowed things down for me.

def ab_seen(experiment, identity, alternative)
if ab_assigned(experiment, identity) == alternative.id
alternative
def ab_seen(*args)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, what do you think about keeping the arguments expanded, e.g. experiment, identity, alternative_id or experiment, identity, alternative_or_id? Condensing down to the splat might make the documentation harder to follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good point - I did it this way because I wanted to avoid shadowing the method parameters with the block parameters, but I hadn't considered the docs. I'll sort this out, thanks. 👍

@urbanautomaton urbanautomaton force-pushed the deprecate-ab-seen-with-alternative-instance branch from 1378e9a to 79c9fa9 Compare November 28, 2016 13:25
Currently all methods in the storage adapter interface that accept an
`alternative` argument accept it in the form of an alternative ID. The
exception to this is `#ab_seen`, which accepts an Alternative instance.

Since third-party code might depend on this, this change at first deprecates
the old usage while allowing both calling styles. The old usage can then be
removed in a future version.
In the previous commit, calling `#ab_seen` with an alternative instance was
deprecated in favour of calling with an alternative id, to bring the method
signature into line with the rest of the abstract adapter API.

This updates the only internal caller to the new style.
@urbanautomaton urbanautomaton force-pushed the deprecate-ab-seen-with-alternative-instance branch from 79c9fa9 to 469917a Compare November 28, 2016 13:33
@urbanautomaton
Copy link
Contributor Author

Thanks for the feedback - I've restored the descriptive parameter names, and used short names for the inner block parameters to avoid shadowing but keep things descriptive.

Please don't apologise for the review time - really appreciate you looking at this series of PRs lately. Hope you had a great holiday. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants