instance method
key_matcher
Ruby on Rails 3.2.22.5
Since v3.0.20Signature
key_matcher(pattern, options)
Add the namespace defined in the options to a pattern designed to match keys. Implementations that support delete_matched should call this method to translate a pattern that matches names into one that matches namespaced keys.
Parameters
-
patternreq -
optionsreq
Source
# File activesupport/lib/active_support/cache.rb, line 443
def key_matcher(pattern, options)
prefix = options[:namespace].is_a?(Proc) ? options[:namespace].call : options[:namespace]
if prefix
source = pattern.source
if source.start_with?('^')
source = source[1, source.length]
else
source = ".*#{source[0, source.length]}"
end
Regexp.new("^#{Regexp.escape(prefix)}:#{source}", pattern.options)
else
pattern
end
end
Defined in activesupport/lib/active_support/cache.rb line 443
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::Store