Class: I18n::Tasks::Scanners::Files::CachingFileFinderProvider
- Inherits:
-
Object
- Object
- I18n::Tasks::Scanners::Files::CachingFileFinderProvider
- Defined in:
- lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
Overview
Note:
This class is thread-safe. All methods are cached.
Finds the files and provides their contents.
Instance Method Summary collapse
-
#get(**file_finder_args) ⇒ CachingFileFinder
Initialize a CachingFileFinder or get one from cache based on the constructor arguments.
-
#initialize(exclude: []) ⇒ CachingFileFinderProvider
constructor
A new instance of CachingFileFinderProvider.
Constructor Details
#initialize(exclude: []) ⇒ CachingFileFinderProvider
Returns a new instance of CachingFileFinderProvider.
13 14 15 16 |
# File 'lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb', line 13 def initialize(exclude: []) @cache = ::I18n::Tasks::Concurrent::Cache.new @defaults = { exclude: exclude } end |
Instance Method Details
#get(**file_finder_args) ⇒ CachingFileFinder
Initialize a I18n::Tasks::Scanners::Files::CachingFileFinder or get one from cache based on the constructor arguments.
22 23 24 25 26 27 28 29 |
# File 'lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb', line 22 def get(**file_finder_args) @cache.fetch(file_finder_args) do args = file_finder_args.dup args[:exclude] = @defaults[:exclude] + (args[:exclude] || []) args[:exclude].uniq! CachingFileFinder.new(**args) end end |