Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Improve and simplify metadata filtering. #2294

Merged
merged 1 commit into from
Jul 18, 2016

Conversation

myronmarston
Copy link
Member

  • Get the value from the metadata hash only once instead of
    multiple times using metadata[key].
  • Try === method instead of treating regular expressions
    as special.

- Get the value from the metadata hash only once instead of
  multiple times using `metadata[key]`.
- Try `===` method instead of treating regular expressions
  as special.
@JonRowe JonRowe merged commit 82146c8 into master Jul 18, 2016
@JonRowe
Copy link
Member

JonRowe commented Jul 18, 2016

Nice!

@JonRowe JonRowe deleted the myron/simplify-metadata-filtering branch July 18, 2016 09:03

meta_value = metadata.fetch(key) { return false }

return true if TrueClass === filter_value && !!meta_value
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we !! the meta_value?

Copy link
Member

Choose a reason for hiding this comment

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

Because TrueClass === '' returns false

Copy link
Member

Choose a reason for hiding this comment

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

Actually ignore that, why do we !! when it's not being evaluated on it's own and it's not being returned?

Copy link
Contributor

@mrageh mrageh Jul 18, 2016

Choose a reason for hiding this comment

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

TrueClass === filter_value && !!meta_value here we use !! and to me it looks like a no-op unless the return value of meta_value can be a non-boolean value.

Copy link
Member

Choose a reason for hiding this comment

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

to me it looks like a no-op unless the return value of meta_value can be a non-boolean value.

It can be a non-boolean value, but thats not an issue if we don't leak it.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok so !! converts it to a boolean value, which is either true or false, thanks @JonRowe

MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
…ering

Improve and simplify metadata filtering.
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.

3 participants