Module: Ramaze::Reloader::Hooks

Included in:
Ramaze::Reloader
Defined in:
lib/ramaze/reloader.rb

Overview

Holds hooks that are called before and after #cycle and #safe_load

Instance Method Summary collapse

Instance Method Details

#after_cycleObject

Overwrite to add actions after the reload rotation has ended.



139
140
# File 'lib/ramaze/reloader.rb', line 139

def after_cycle
end

#after_safe_load(file) ⇒ Object

Overwrite to add custom hook in addition to default Cache cleaning



157
158
# File 'lib/ramaze/reloader.rb', line 157

def after_safe_load(file)
end

#after_safe_load_failed(file, error) ⇒ Object

Overwrite to add actions after a file is Kernel::load-ed unsuccessfully, by default we output an error-message with the exception.



162
163
164
# File 'lib/ramaze/reloader.rb', line 162

def after_safe_load_failed(file, error)
  Log.error(error)
end

#after_safe_load_succeed(file) ⇒ Object

Overwrite to add actions after a file is Kernel::load-ed successfully, by default we clean the Cache for compiled templates and resolved actions.



149
150
151
152
153
154
# File 'lib/ramaze/reloader.rb', line 149

def after_safe_load_succeed(file)
  Ramaze::Cache.compiled.clear
  Ramaze::Cache.resolved.clear
  Ramaze::Cache.action_methods.clear
  after_safe_load(file)
end

#before_cycleObject

Overwrite to add actions before the reload rotation is started.



135
136
# File 'lib/ramaze/reloader.rb', line 135

def before_cycle
end

#before_safe_load(file) ⇒ Object

Overwrite to add actions before a file is Kernel::load-ed



143
144
145
# File 'lib/ramaze/reloader.rb', line 143

def before_safe_load(file)
  Log.debug("reload #{file}")
end