Method: Guard.run_on_guards

Defined in:
lib/guard.rb

.run_on_guards(scopes = {}) ⇒ Object

Loop through all groups and run the given task (as block) for each Guard.

Stop the task run for the all Guards within a group if one Guard throws ‘:task_has_failed`.

Parameters:

  • An (Hash)

    hash with a guard or a group scope



246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/guard.rb', line 246

def run_on_guards(scopes = {})
  if guard = scopes[:guard]
    yield(guard)
  else
    groups = scopes[:group] ? [scopes[:group]] : @groups
    groups.each do |group|
      catch :task_has_failed do
        guards(:group => group.name).each do |guard|
          yield(guard)
        end
      end
    end
  end
end