Class: Bootscale::CacheBuilder
- Inherits:
-
Object
- Object
- Bootscale::CacheBuilder
- Defined in:
- lib/bootscale/cache_builder.rb
Instance Method Summary collapse
- #clear! ⇒ Object
-
#generate(load_path, rescan = false) ⇒ Object
generate the requireables cache from all current load-path entries each load-path is cached individually, so new ones can be added or removed but added/removed files will not be discovered.
-
#initialize ⇒ CacheBuilder
constructor
A new instance of CacheBuilder.
Constructor Details
#initialize ⇒ CacheBuilder
Returns a new instance of CacheBuilder.
3 4 5 |
# File 'lib/bootscale/cache_builder.rb', line 3 def initialize @entries = {} end |
Instance Method Details
#clear! ⇒ Object
7 8 9 |
# File 'lib/bootscale/cache_builder.rb', line 7 def clear! @entries = {} end |
#generate(load_path, rescan = false) ⇒ Object
generate the requireables cache from all current load-path entries each load-path is cached individually, so new ones can be added or removed but added/removed files will not be discovered
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bootscale/cache_builder.rb', line 14 def generate(load_path, rescan = false) requireables = load_path.reverse_each.flat_map do |path| path = path.to_s if rescan entries[path] = Entry.new(path).requireables else entries[path] ||= Entry.new(path).requireables end end Hash[requireables] end |