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

Remove request.features #3

Merged
merged 4 commits into from Feb 21, 2014
Merged

Remove request.features #3

merged 4 commits into from Feb 21, 2014

Conversation

ghost
Copy link

@ghost ghost commented Feb 20, 2014

Decorating the request object causes issues if a Reflip-enabled Express app mounts a Reflip-enabled sub-app with different settings. If app A configures Reflip with "aardvarks" enabled, app B configures an independent Reflip instance with "aardvarks" disabled, and A mounts B as a sub-app, request.features.aardvarks will be false if A mounts B after reflip.flip(), and true if A mounts .flip() after B.

The internal cache of feature lookups is now exposed by calling request.check() without any arguments. Mutating this object will affect the results returned by request.check('feature-name'), consistent with the current behavior.

This is a backward-incompatible change, though. What do you think, @ceejbot?

Kit Cambridge added 4 commits February 20, 2014 14:49
Decorating the `request` object causes issues if a Reflip-enabled
Express app mounts a Reflip-enabled sub-app with different settings.
For example, if app A configures Reflip with the `"aardvarks"` setting
enabled, app B configures an independent instance of Reflip with
`"aardvarks"` disabled, and A mounts B as a sub-app,
`request.features.aardvarks` will be `false` if A mounts B after
mounting the `flip` middleware, and `true` if A mounts `flip` after
B.

Instead of adding a separate `exportFeaturesName` option,
`request.check()` now returns an object of feature names and their
corresponding states if it is called without any arguments.

This is a backward-incompatible change.
This allows features named `hasOwnProperty`. Isolate the `try...catch`
statement around `JSON.parse()` in `FileAdapter#read()`.
`request.check()` now returns the internal cache instead of
constructing a new object. Mutating this object will affect the
results returned by `request.check('feature-name')`. This is
consistent with the v0.2.4 behavior.
@@ -18,7 +18,7 @@ var Reflip = module.exports = function(opts)
assert(opts.storage || opts.features, 'You must pass either storage options or a pre-set feature object');

if (opts.features) this.features = opts.features;
if (opts.hasOwnProperty('default')) this.default = opts.default;
if (_.has(opts, 'default')) this.default = opts.default;
Copy link
Owner

Choose a reason for hiding this comment

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

Your lodash fu is stronger than mine.

ceejbot added a commit that referenced this pull request Feb 21, 2014
@ceejbot ceejbot merged commit d7f1655 into ceejbot:master Feb 21, 2014
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.

1 participant