class PgConn::SessionMethods

def triggers(on_off, &block)

Execute block with session triggers on or off
def triggers(on_off, &block)
  begin
    active = triggers?
    if on_off && !active
      enable_triggers
    elsif !on_off && active
      disable_triggers
    end
    yield
  ensure
    case active
      when true; enable_triggers if !triggers?
      when false; disable_triggers if triggers?
    end
  end
end