Class: RailsDevelopmentBoost::LoadedFile::Files
- Inherits:
-
Hash
- Object
- Hash
- RailsDevelopmentBoost::LoadedFile::Files
- Defined in:
- lib/rails_development_boost/loaded_file.rb
Instance Method Summary collapse
- #constants ⇒ Object
- #each_file_unload_if_changed ⇒ Object
-
#initialize(*args) ⇒ Files
constructor
A new instance of Files.
- #stored?(file) ⇒ Boolean
- #unload_decorator_file(file) ⇒ Object
- #unload_modified! ⇒ Object
- #unload_modified_file(file) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Files
Returns a new instance of Files.
4 5 6 |
# File 'lib/rails_development_boost/loaded_file.rb', line 4 def initialize(*args) super {|hash, file_path| hash[file_path] = LoadedFile.new(file_path)} end |
Instance Method Details
#constants ⇒ Object
36 37 38 |
# File 'lib/rails_development_boost/loaded_file.rb', line 36 def constants values.map(&:constants).flatten end |
#each_file_unload_if_changed ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rails_development_boost/loaded_file.rb', line 12 def each_file_unload_if_changed unloaded_something = false values.each do |file| if yield(file) unload_modified_file(file) unloaded_something = true end end if unloaded_something values.each do |file| unload_decorator_file(file) if file.decorator_like? end end unloaded_something end |
#stored?(file) ⇒ Boolean
40 41 42 |
# File 'lib/rails_development_boost/loaded_file.rb', line 40 def stored?(file) key?(file.path) && self[file.path] == file end |
#unload_decorator_file(file) ⇒ Object
32 33 34 |
# File 'lib/rails_development_boost/loaded_file.rb', line 32 def unload_decorator_file(file) file.unload! end |
#unload_modified! ⇒ Object
8 9 10 |
# File 'lib/rails_development_boost/loaded_file.rb', line 8 def unload_modified! each_file_unload_if_changed {|file| file.changed?} end |
#unload_modified_file(file) ⇒ Object
28 29 30 |
# File 'lib/rails_development_boost/loaded_file.rb', line 28 def unload_modified_file(file) file.unload! end |