Method: Guard::Dsl#callback
- Defined in:
- lib/guard/dsl.rb
#callback(*args) { ... } ⇒ Object
Defines a callback to execute arbitrary code before or after any of the start, stop, reload, run_all, run_on_changes, run_on_additions, run_on_modifications and run_on_removals plugin method.
246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/guard/dsl.rb', line 246 def callback(*args, &block) @plugin_options ||= nil fail "callback must be called within a guard block" unless @plugin_options block, events = if args.size > 1 # block must be the first argument in that case, the # yielded block is ignored args else [block, args[0]] end @plugin_options[:callbacks] << { events: events, listener: block } end |