Class: Lookbook::Reloaders
- Inherits:
-
Object
- Object
- Lookbook::Reloaders
- Defined in:
- lib/lookbook/reloaders.rb
Defined Under Namespace
Classes: Reloader
Instance Attribute Summary collapse
- #reloaders ⇒ Object readonly
Instance Method Summary collapse
- #add(name, directories, extensions, &callback) ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ Reloaders
constructor
A new instance of Reloaders.
- #register_changes(changes) ⇒ Object
Constructor Details
#initialize ⇒ Reloaders
Returns a new instance of Reloaders.
7 8 9 |
# File 'lib/lookbook/reloaders.rb', line 7 def initialize @reloaders = [] end |
Instance Attribute Details
#reloaders ⇒ Object (readonly)
5 6 7 |
# File 'lib/lookbook/reloaders.rb', line 5 def reloaders @reloaders end |
Instance Method Details
#add(name, directories, extensions, &callback) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/lookbook/reloaders.rb', line 11 def add(name, directories, extensions, &callback) reloader = Reloader.new(name, directories, extensions, &callback) reloaders.push(reloader) if Engine.reloading? Rails.application.reloaders << reloader Rails.application.reloader.to_run { reloader.execute_if_updated } end end |
#execute ⇒ Object
21 22 23 |
# File 'lib/lookbook/reloaders.rb', line 21 def execute reloaders.each { |reloader| reloader.execute } end |
#register_changes(changes) ⇒ Object
25 26 27 28 |
# File 'lib/lookbook/reloaders.rb', line 25 def register_changes(changes) reloader = reloaders.find { |reloader| reloader.watching?(changes) } reloader.last_changes = changes if reloader end |