Class: RSpec::Core::FilterableItemRepository::QueryOptimized

Inherits:
UpdateOptimized
  • Object
show all
Defined in:
lib/rspec/core/metadata_filter.rb

Overview

This implementation is much more complex, and is optimized for rare (or hopefully no) updates once the queries start. Updates incur a cost as it has to clear the memoization and keep track of applicable keys. Queries will be O(N) the first time an item is provided with a given set of applicable metadata; subsequent queries with items with the same set of applicable metadata will be O(1) due to internal memoization.

This is ideal for use by config, where filterable items (e.g. hooks) are typically added at the start of the process (e.g. in spec_helper) and then repeatedly queried as example groups and examples are defined.