Navigation Menu

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

Add Criteria#<<(criterion) to stop repetition #68

Merged
merged 1 commit into from Jul 3, 2014

Conversation

erran-r7
Copy link
Contributor

@erran-r7 erran-r7 commented Jul 1, 2014

Prior to this change Nexpose::DynamicAssetGroup#criteria accessor was used to get the DAG's criteria, Criteria#criteria was then used to get the actual array following Array#<<(criterion) which would be used to add a new criterion. Producing the longer syntax dag.criteria.criteria << my_new_criterion vs. my_dag.criteria << my_new_criterion.

Before

dag = Nexpose::DynamicAssetGroup.new('test123')
criterion = Nexpose::Criterion.new(Nexpose::Search::Field::OS, Nexpose::Search::Operator::CONTAINS, 'linux')
dag.criteria = Nexpose::Criteria.new

# We needlessly repeat criteria here
dag.criteria.criteria << criterion

After

dag = Nexpose::DynamicAssetGroup.new('test123')
criterion = Nexpose::Criterion.new(Nexpose::Search::Field::OS, Nexpose::Search::Operator::CONTAINS, 'linux')
dag.criteria = Nexpose::Criteria.new

# This is more straight forward
dag.criteria << criterion

Prior to this change `Nexpose::DynamicAssetGroup#criteria` accessor was
used to get the DAG's criteria, `Criteria#criteria` was then used to
get the actual array following `Array#<<(criterion)` which would be
used to add a new criterion. Producing the longer
syntax `dag.criteria.criteria << my_new_criterion` vs. `my_dag.criteria
<< my_new_criterion`.
@jhart-r7
Copy link
Contributor

jhart-r7 commented Jul 2, 2014

Agreed, this is much cleaner.

mdaines-r7 added a commit that referenced this pull request Jul 3, 2014
Add `Criteria#<<(criterion)` to stop repetition
@mdaines-r7 mdaines-r7 merged commit b8011b8 into rapid7:master Jul 3, 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.

None yet

4 participants